I've done a bit of work on the Real Estate website that I support for a client, so I thought I'd discuss a few things I learned about using Google maps with listings in your website.
When I first set up the clients site, I set up a little logic to dynamically put a link to a Google map showing the location of the property on a map. So, based on the address fields in the database, I would print out something like:
http://maps.google.com/maps?q=14700 Hilltop Drive, Somerset, MI 49281&spn=0.026496,0.043460&hl=en
Where the address is, obviously, 14700 Hilltop Drive, Somerset, MI 49281.
This gives a map that looks as follows when clicked on:
The problem with this though, is that Google just can't resolve some addresses. It's not really Googles fault, as pinpointing a location on a map based on a street address is prone to all kinds of problems. I'll give just one example of that.
My client lives in a rural area of Michigan. When post offices were first created in the area in the early part of the century, the locations were based on the towns that thrived around the railroad (believe it or not). A couple of these junctions were the towns of Cement City and Jerome. These towns, and Jerome in particular, are quite small. In the last 20 or 30 years, Lake communities have spring up at both Lake Somerset and Lake LeAnn whose populations are much larger. But mailing addresses for many around Lake Somerset are still Cement City to this day. Likewise, many homes around Lake LeAnn still have mailing addresses of Jerome, even though its several miles away.
Ok enough of the example. What's a better method than using mailing addresses to create a map? The best way is to use latitude and longitude and create a slightly different link, that would look as follows:
http://maps.google.com/maps?hl=en&q=42.05202,-84.385208&ie=UTF8&ll=42.05202,-84.385208&spn=0.06326,0.129089&z=15
The Google page that comes up when you click on the link looks like this:
While the accuracy is good you'll notice that the location on the map is labeled only by the latitude and longitude this time, which isn't as nice. I suspect that there's a way to correct that by adding other parameters to the url but I haven't had time to tinker with it. If your interested, you can find some Google Maps parameter info here.
In addition to the above described techniques, its also quite easy to embed static google maps on a website. Just use Google maps, and when you get the map you'd like to embed on your website, click the "link" link just above the map to the right, as shown below:
Then paste the resulting code into your website in the spot you want to use it. I did find though, that Google won't allow you to use that as a template and dynamically alter the parameters to show different maps. Your given an ID and its good for that one map.
To get really serious about utilizing Google maps in your Real Estate or other map related website, check out the Google Maps API. With this you can do quite a bit more than anything I've described above.
No comments:
Post a Comment