Visualizing Geo-location Data with Google Map

Visualizing geo-location data is often more involved than other types of data because you probably want to put them into the context of places instead of just latitude-longitude values. There are many solution to this problem and mine might not be the best or the easiest. Please share your thoughts in comments if you have a better solution. So my solution is to place your data on Google map with their static image API: it can provide street views too!

Using Google Map Static Image API
To illustrate how easy this is, I will use some examples as well as links to the relevant entries in the reference. The basic idea is that all data (and other parameters) are passed in a request to Google in the URL string and then the rendered static image will be returned as a response.

Marking locations
This self-explanatory URL will give you a map with four lat-long pairs (41.791421,-87.598077), (41.791391,-87.599692), (41.790013,-87.599676), (41.790021,-87.599193) marked on a map:

which will return the image below:

The basic syntax for the parameters is: 
markers=[markerStyles|]markerLocation1| markerLocation2|...
Marking a path
To link up the lat-long pairs marked in the previous section, simply substitute "marker" with "path": 

  1. You can apply different styles (e.g. color) to paths (or markers) to discern multiple paths in one image.
  2. Since there is often a limit on the length of request URL, you might need to squeeze your lat-long pairs in by encoding them: https://developers.google.com/maps/documentation/staticmaps/#EncodedPolylines
  3. You can also have both markers and path at once by concatenating the parameters like such:  http://maps.googleapis.com/maps/api/staticmap?size=800x800&markers=41.791421,-87.598077|41.791391,-87.599692|41.790013,-87.599676|41.790021,-87.599193&path=41.791421,-87.598077|41.791391,-87.599692|41.790013,-87.599676|41.790021,-87.599193&sensor=false
  4. You can use addresses instead of latitude-longitude pairs: http://maps.googleapis.com/maps/api/staticmap?size=800x800&markers=Chicago|DC|San%20Francsico&sensor=false

No comments:

Post a Comment