This is the basic structure of a data call to Yahoo Maps’ API. This will draw a 500px by 300px map centered on Wired’s San Francisco offices, complete with zoom and pan controls. When the user clicks on the location marker, a pop-up box will appear with some text inside.
All of these attributes can be changed by modifying the code below. You’ll need to use your own API key.
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.
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.