One of the primary uses of a map has always been to figure out how to get from point A to point B. Until now the only way users of our Maps API v3 could put directions on their map was to draw a straight polyline and tell people to fly. Well, fret no more: we've just released Directions in v3, and rather than just porting it over from v2, we've given it a complete makeover and hope you'll like the new look.
So, what does the new Directions interface look like? We've split the GDirections object from v2 into two separate classes that work together to give you routing goodness. DirectionsService passes directions queries to our server and returns the results in JSON format, while DirectionsRenderer displays the results on your map. The 'load' event from v2 has been removed; instead, a callback function containing your rendering code is passed to the DirectionsService when making a new query.
We've also introduced a couple of options for specifing the kind of results that you want returned from our server. If there's more than one way to get from A to B, you can opt to retrieve all of them with provideTripAlternatives, and if the imperial system offends you, just tell the DirectionsService that you always want metric units returned by using unitSystem. Here's a code snippet that adds directions to a map and step-by-step instructions to an accompanying panel, as well as specifying both of the new options:
provideTripAlternatives
unitSystem
var map = new google.maps.Map(document.getElementById("map_canvas"), { zoom: 7, mapTypeId: google.maps.MapTypeId.ROADMAP, center: new google.maps.LatLng(-33.868011, 151207566) }); var directionsRenderer = new google.maps.DirectionsRenderer(); directionsRenderer.setMap(map); directionsRenderer.setPanel(document.getElementById('directionsPanel')); var directionsService = new google.maps.DirectionsService(); var request = { origin: "Sydney, NSW", destination: "Chatswood, NSW", travelMode: google.maps.DirectionsTravelMode.DRIVING, unitSystem: google.maps.DirectionsUnitSystem.METRIC, provideTripAlternatives: true }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsRenderer.setDirections(response); } else { alert('Error: ' + status); } });
You'll get something that looks like this:
To get started, take a look at the reference and an explanation of the concepts involved, as well as the examples. As always, tell us if you have any questions or comments. We may not choose the most interesting route for you to travel on, but you can rest assured that if you ever want to drive from Seattle to Honolulu, we'll...draw a straight polyline and tell you to kayak*.
Bon voyage!
* because we don't know if your car is watertight.
Just like Ricky Bobby, I like going fast. Most of the time, though, going too fast in real life can be dangerous. That's why I also enjoy playing driving games and simulators—all from the comfort and safety of my own home!
The great thing is, thanks to the Earth API and Maps API for Flash, developers have built a flurry of simulator applications that are visually stunning, geographically realistic, and highly addictive. Below are some of my favorite simulators for driving, sailing, running, and even landing on the moon!
WARNING: I will not be held liable for any lost productivity resulting from these awesome apps!
Considered by most to be in the list of top Earth API apps, Ships is a highly polished simulator by New Zealand-based Dinther Product Design for a variety of sea vessels (and a blimp!). The visual effects (i.e. the ship's wake using animated ground overlays), camera angles, and detailed screen overlay-based dials make Ships an exceptionally fun and immersive simulator.
Primary API: Earth API
Although I don't have the endurance to run a marathon, I can still check out various marathon routes with the help of Race My Race! This app is a really fun way to explore the terrain along these difficult routes. And, if you're planning on running a marathon in the near future, this site can even help you prepare!
Ever want to explore the world's great bodies of water? Sea-Seek's Virtual Dive is perfect for just that! This app lets you commandeer a variety of air, ocean surface, and underwater vessels along coastlines and even in the deep blue sea! My favorite vessel is the 'Shark Sub,' equipped with a headlamp model.
The original, 2D version of this simulator was very impressive—it allowed you to drive a car or truck in a city of your choosing in a Grand Theft Auto-like perspective. This version, however, one-ups the original by utilizing the new 3D perspective in the Maps API for Flash with a 3D car model for a more realistic feel. A great game from a great developer in Japan!
Primary API: Maps API for Flash
Another gem from Dinther Product Design, this challenging, but very fun, minigame lets you attempt to land the Apollo 11 Moon Lander. I personally have never been able to land without crashing, but a few of my coworkers had no problem finishing with a successful 'Eagle Touchdown.' To them, I say: apply to NASA!
This is a super-mashup of a number of Google and non-Google APIs, allowing you to visualize—in every way imaginable—the driving route between two addresses. The demo really shows off what's possible with today's geo platforms. Very exciting stuff!
Primary API: Various
I hope you enjoyed trying out these simulators; maybe a few of you were inspired to write your own simulation apps! I bet we'll be seeing more and more of these types of apps in the future. 'Til next time, thanks for reading and drive safely!
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&language=pt-BR">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false®ion=GB">
How does this update impact developers? First, you can use the new "Report a Problem" link on maps to communicate directly with Google about any updates or corrections that you think need to be made to our maps. Second, the data that powers API features like geocoding and driving directions has also been updated. If you're using client-side geocoding in the browser, your applications will automatically start using the new data. If you've been using the HTTP geocoder and caching any retrieved data, you should re-geocode with the new data as soon as possible. With the "Report a Problem" feature, we'll be updating the map data regularly, so we recommend that you continue to refresh any cached data in order to take advantage of corrections from our users.
As always, if you have any questions or feedback about how this change affects your use of the API, you should post to the relevant forum:
We're excited about the changes we're making today! For those of you overlaying data and creating Google Maps applications for the United States, we hope that the underlying base map will continue to evolve, just like the amazing mapping tools that you are maintaining.
Posted by Michael Weiss-Malik, Software Engineer
Since we launched AdSense for Maps many developers have shared their experiences with monetizing their Google Maps API implementations. Here is a detailed, first hand account from one developer..
Hi, I'm Martin Fröhlich from Maplandia, a world gazetteer based on Google Maps. I'm delighted to share our experience with recently launched monetization tools available through the Google Maps API. We have been successfully using traditional AdSense to monetize our traffic for some time, so we were happy when the Geo Developers Blog announced two new ways how to generate revenue designed purely for Maps.
There are some significant advantages of Maps Ad Unit in comparison to classic ad units: the relevance of ads is determined not only by the content of the page but also from what is currently shown on the map itself. The other advantage is that the ads are updated (re-targeted) each time a user moves or zooms the map, so they are always tailored to what is viewed on the map.
These two reasons lead to more relevant ads. From the entrepreneurial point of view, this leads to more revenue which is very important to us. We have experienced a 35% increase in our daily revenue from AdSense For Content (This number stands for the portion of total revenue generated by our Maps Ad Unit channel, calculated for the last two months since we implemented the Maps Ad Unit). We didn't notice any decline in the revenue from other AdSense ads placed on the page, so this is really pure increase of profit. The only drawback was that we had to remove GOverviewMapControl (which I always liked) due to the ads. However, this is not necessary if you decide to place ads in other than bottom right corner.
Finally, the implementation is really simple, consisting of adding these few lines to your code:
var publisher_id = yourPublisherID; var adsManagerOptions = { maxAdsOnMap : 2, style: 'adunit', // The channel field is optional - replace this field with a channel number // for Google AdSense tracking channel: 'your_channel_id' }; adsManager = new GAdsManager(map, publisher_id, adsManagerOptions); adsManager.enable();
GoogleBar was introduced back in 2007, but only the latest update made it possible to monetize this search experience. We have a lot of visitors looking for many different places all over the world. Unfortunately, there are (and always will be) some places we can't provide any information on, so this is why I find GoogleBar with its local search functionality to be a very useful tool for our users. Advertising revenue from GoogleBar is a nice bonus: adding GoogleBar to our maps more than doubled our daily revenue from AdSense for Search (which we used with Google Custom Search Engine already).
On Maplandia we have been using both these features together for more than two months now. So far, the results are impressive. There are plenty of mashups with much less non-map content than we tend to have. I sincerely believe that those of you with these types of sites can easily beat our AdSense revenue increase numbers. I highly recommend trying Adsense For Maps, if you haven't done so yet. Good luck and happy coding!
Give us feedback in our Product Forums.