Archive

Posts Tagged ‘google maps’

Google Maps API Alternative: the Static Maps API

February 10th, 2009

If you are looking into adding some map functionality to your app or web site, remember to also consider the Static Maps API for a non-interactive version of Google’s maps. This static API takes a list of parameters such as the map center, width & height, any markers or path data… and returns a static IMAGE instead of using javascript to render your map.

You won’t be able to interact with the map… but the main advantage here is speed.  The javascript needed to run the regular Google Maps API is quite heavy.  It doesn’t run well on mobile browsers and can take a few extra seconds to finish loading on regular desktop browsers as well.  So, if all you need is a nice looking map, the static API is a great choice.

For example, it seems to load a good 10x faster than the regular Google Maps API when loaded into a UIWebView controller on the iPhone.  Even on a wifi connection, the javascript API takes a good 5-10 seconds to show up, whereas the static image API loads almost instantly.  For mobile devices, speed currently trumps functionality in many cases such as this one.  The user won’t be able to pan and zoom, but they won’t complain if the map loads fast :-)

We are using the static maps API in our Rotzy iPhone app and will just give users the option of clicking on it and bringing up the native Google Maps application if they really want to pan and zoom.

Here’s an example of how easy it is to generate a map by simply passing paramters to the API url:

# Note that this URL wraps at the '\' character.
# For clarity, we don't write the actual API key in use.
#
http://maps.google.com/staticmap?center=40.714728,-73.998672\
&zoom=14&size=512x512&maptype=mobile\
&markers=40.702147,-74.015794,blues%7C40.711614,-74.012318,\
greeng%7C40.718217,-73.998284,redc\
&key=MAPS_API_KEY&sensor=false

The code above will generate a map that looks like this:

staticmap

Read more and get the full documentation here.

Gee API, Projects, Tips , , ,