Wednesday, May 27, 2009

Announcing Google Maps API v3

Since our last major release of the JavaScript Maps API three years ago we've been delivering feature requests that all of you have been asking for month over month. With over 150,000 active websites implementing it, the Maps API has become one of the most popular and trusted developer tools on the web. We're in the process of giving the Maps API a major facelift and today we're providing you a look at V3 in our Google Code Labs.

The primary motivation behind this new version was speed, especially for rendering maps on mobile browsers. Last year, several of us starting thinking about the possibility of getting the JavaScript Maps API to work on mobile devices. With the advent of powerful, fully functional browsers on devices such as the iPhone and the Android-based G1, why couldn't we bring the flexibility and reach of modern web development to people who wanted to write maps mashups for mobile phones? While we've been able to get the existing v2 API working on mobile browsers, we found we were constrained when trying to reduce latency and we needed a new approach. And thus was born the idea for the next revision of the Maps API.

We wanted to get this in your hands as soon as possible, so we've intentionally released it early, and with a basic set of features. We're releasing it in Labs because it's not fully baked yet; we want to get your feedback on the new design and what you'd like to see in future revisions now that we have a chance for a fresh start. Yes, this does mean that you'll have to rewrite your existing mashup code if you want to take advantage of v3, but we think that speed is very important to a great user experience.

What's changed in v3? Besides the substantial improvements in speed, a few other things that you'll notice in the initial release:

  • iPhone Safari mobile and Chrome added to our supported browsers. Your mashups will also work on Android-based phones with the recent update, but you may notice some issues, like the "View/Save Image" dialog showing unexpectedly. We're working with the Android team to fix this and improve the end user's experience in interacting with the map. We could've waited until it's perfect, but we really wanted to get an early release in your hands and start getting feedback while we fix up a few remaining issues.
  • No keys required. You can now copy 'n paste code easily or embed in RSS readers, for example, without getting key errors.
  • MVC-based architecture. This allowed us to significantly reduce the size of our initial JavaScript download. We found it to be simple and powerful.
  • Default UI is enabled automatically. We'll provide default UI controls and behavior (and we'll update them) so your mashup can keep up with the latest and greatest changes we make to Google Maps. Of course, if you've got customized controls you're happy with, you can disable the default UI updates.
  • Namespaces. Everything is always in the google.maps.* namespace and there is no "G" prefixed variables in the global scope.
  • Geocoding API has been overhauled based on the feedback we've received with the existing implementation over the past three years.
Check out the reference and documentation for more details.

What does the API look like? Here's a quick, complete example that you can grab to render a map. It's even set up to render a full-screen interactive map on the iPhone and Android browsers.


<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
  function initialize() {
    var latlng = new google.maps.LatLng(-34.397, 150.644);
    var myOptions = {
      zoom: 8,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  }
</script>
</head>
<body onload="initialize()">
 <div id="map_canvas" style="width:100%; height:100%">
</body>
</html>

We've set up a new group for you to provide feedback. Also, the terms have been updated to remind you that versions we release as "experimental" or in Labs may not have the same level of support as ones that are already out of Labs. This means that we'll continue to support the current v2 API well after v3 matures and graduates from Labs. In the meantime, we're looking forward to adding a lot more functionality to this new release so please send us your feedback!