Jun 14, 2009

Google Maps Helper

Author: gaweee | Filed under: development, howto

In our work we like to create Google Maps links for our client’s (offices, stores, etc). However, the larger our clients presence, the more random links there are bound to be. When it comes to using Google Map’s javascript API to control the map, thats still perfectly fine. But how do I create a google maps link that only shows 1 entry? Turns out, there are several ways to do this:

  1. Manipulate the request such that it only shows your entryHow? For example, searching for “Holland, Singapore” will lead us to about 1,356 results. See here. So lets tweak it a little:
    • Append &mrt=yp to the url – That returns us all the business listings. (852 results)
    • Append &start=16 to the url – That skips the first 16 results (Shows results 17-26 of 852)
    • Append &num=2 to the url – That returns us only 2 results (Only shows 2 results)

    For a more complete listing of Google Maps Parameters, consult mapki.com. Kudos to those guys for compiling that list. Really useful stuff
    So there you have it, a simple way to link your business such that its the only entry there. However this method is relatively dangerous. Why? Cause you’ve got no idea of the exact ordering that Google maps may return. Today you could be entry 17, surely not in a year (hopefully for the better). As such, this is not the recommended solution.

  2. Use the address with your long/lat coordinates to generate your entry.
    • First get your GPS coordinates, there are a number of ways to do this. Check our this link
    • Then create your link via the following structure: http://www.google.com/maps?&ie=UTF8&hl=en&q=[urlescaped address]&ll=[GPS lat,long]&z=[Zoom]&iwloc=A
    • Still too troublesome? We’ve created a simple tool for our clients to use. Save yourself some time. Try it!
    • Done! Whats the downside to this? You can only show the address for the business. Because searching by business names returns us way too many results. So instead, we have to search for an address, Google interprets this as an address and only returns 1 result (which is the whole point of geocoding). At this point its easy to the map to what we need. We’d use this typically for this nifty little “Find us on a map” links (instead of embedding the actual map on your site).

Once again, if you’d rather embed Google maps directly into your site via the JS, then your options are much more open.
Good luck! Let us know if it works for you, of if you find a better way of doing things!
googleMapsHelper


Leave a Reply