Google Maps is perhaps the biggest and most useful of all the common web APIs. Who doesn’t love clicking and dragging those sleek, clean maps? But it’s also one of the more complex APIs, which can be intimidating for newcomers. It’s also somewhat difficult to immediately recognize all the possibilities of the Google Maps API since there are literally hundreds of ways to use it.
We’re going to dive right in. But to keep things simple, we’ll start with a very common use: Adding a map to your site and displaying some markers.
It seems every mapping website has an API these days. Google, Yahoo, Microsoft, Mapquest… how do you choose? With Mapstraction, you don’t have to.
Mapstraction is an open source abstracted JavaScript mapping library. You can write mapping code once, then switch between map providers by only changing two lines. Mapstraction is maintained by a group of geocode lovers who want to give developers options when creating maps.
To help you on your way to using Mapstraction, we’ll simply create a map we can display on a web page, and then add a marker to denote a particular location.
Mashups, web apps which merge two or more data sources, essentially arose from the introduction of the Google Maps API in June 2005. APIs for easily accessing data existed before then, but a way to visualize it geographically was a huge tipping point.
Due to the popularity of map mashups, ProgrammableWeb’s mashup directory is over a third mapping-related. But something interesting has been happening: other types of mashups are becoming popular. Over the last two weeks, for example, maps mashups are only 20% of the new additions to the directory. Granted, it’s a small sample and mapping is still tops by far, but other ways of mashing up data are becoming more relevant.
How can mashups be both dead and more relevant? Consider Friendfeed, which aggregates your data using APIs of several social websites, pulling in each item you and your friends post to Twitter, Flickr, Digg, your blogs. It fits the criteria of a mashup perfectly. If Friendfeed was entered into the recent MashupCamp contest, it would have come away victorious. Friendfeed is an uber-mashup, though nobody calls it that.
Mashups are dead because the whole web is becoming a collection of APIs. In the future, showing an embedded map of liquor stores near that New Year’s party won’t be a snazzy add-on, it will be a necessary feature.
What’s cooler than Google Maps? Tools built on top of it. Developers from the Netherlands have released some helpful libraries to make more usable, interactive Google Maps.
Google hosts an open source utility library with several useful examples. Among them, a drag-to-zoom feature and a way to create dynamic labeled markers.
A progress bar is among the new additions to the libraries. When adding more than just a few markers, it can take some time. Rather than make your users sit through the slow-down, this library shows the progress via a popup status bar that fills as it completes.
The other new library, SnapToRoute, allows developers to restrict some actions to just along a polyline. The example included shows zooming along a specific route.
I love these sorts of libraries that make creating advanced maps easy. Of course, I’d love to see platform-independent examples, so developers of any map API could benefit. These libraries would be great to see as a part of Mapstraction, the multi-map I covered in a tutorial.
Toss out that MySQL book. The only thing you need to store location data is Google Maps.
My Maps is a feature that lets you create your own mashup on a map. Once a map is created, it can be shared with a link, or in Google Earth with a KML file. And now, it is also available via RSS–GeoRSS, to be more specific.
While viewing any My Map, click the RSS link to see the GeoRSS version of the map. In addition to all the other information about points on the map, such as business name and address, you get latitude and longitude coordinates.
This RSS feed can then be read in by any script you write instead of making a database call. The Google Maps API can even call GeoRSS files directly, loading all your locations in a single line.