Implementing a selection box for Google Maps
This method only works with the first version of Google
Maps. It does not work with the latest API. I have not
had the time to update the code but I am sure if you
search Google you will find an implementation using the
latest API.
I really like Google Maps but one thing that has been
bothering me for a while was the inability to select an
area on the map to zoom into.
With the help of the Google Maps API which allows you embed the maps on your own page, I decided to tackle the problem of implementing the selection box.
Well, after around 7 hours of work/hacks/coffee this evening, I had it working on IE and Firefox. I hope that Google implements this feature soon.
v2 demo and source code here To zoom into an area, press the shift +
'z' key and move your
mouse.
v1 demo and source code here To zoom into an area, press the 'z' key and
move your mouse.
TODO: Re-Initialize on resize; Take into account scroll
attributes if map is being scrolled. I'll let Google take
care of that when they implement this ;-)
The API could have exposed more functions and the documentation should bee improved. Hopefully they will in the next
release. Since the current API only allows you to render
an area given the lat, lon of the center and a zoom level,
the challenge was converting the pixels of my bounding box
to lat/lon coordinates, finding the center and then
determining the appropriate zoom level. I think the API in
the future should alow a developer to call a method that
renders the map given the lat/lon or pixels of your
bounding box.
It is almost 4 am..I need some slee