Starting today – and going until next week – I will be writing a post, everyday, detailing a chunk of Google Maps API-enhancing code that I’ve written. During the past couple weeks I’ve been working a number of contract jobs – all of which have centered around the usage of the Google Maps API, a powerful tool for programmers. As I’ve gone along, there have been a number of features that I’ve developed (or found) that I think other programmers would benefit from knowing. Today is going to be a double-whamy.
First: Geocoding addresses for Google Maps. This is probably the first thing that people ask for when using the API. Thankfully there are plenty of free services available that can be harnessed to make Geocoding a reality. I wrote a chunk of Javascript (with an associated Perl script) a little while ago that acheives this goal. Unfortunately, some people still seem to have trouble finding it – so it deserves another link to. Feel free to read [link] the full release for more information.
You can view a demo of this modification here.
Second: Click Zoom This enhancement is so simple – I love it. In a nutshell: You can now click anywhere on a map to zoom in. Thankfully, you can still grab-drag the map around without being effected. After having implemented it in one particular application, I’ve become addicted to it – it’s so handy! I use it by simply clicking the name of a city (or location) that I want to jump to. It’s so much easier then re-centering and clicking the ‘Zoom’ button every step of the way. The code is short, so feel free to give it a try:
GEvent.addListener( map, "click", function(o,p) { if ( o != null ) return; if ( map.getZoomLevel() > 1 ) map.centerAndZoom( p, map.getZoomLevel() - 2 ); else if ( map.getZoomLevel() == 1 ) map.centerAndZoom( p, 0 ); });
I have the code set to zoom in two levels every time you click, but this can be tweaked to be less aggressive. At some point, I think it would be neat to add ‘Right Click Zooms Out’ functionality – unless, of course, someone beats me too it.
You can view a demo of this modification here.
Bob Aman (August 12, 2005 at 9:49 pm)
I approve!
Jon (August 13, 2005 at 9:16 pm)
Someone is paying contractors to use the Google API? I thought it was just for fun and games…
Googling, Blogging and PHP (August 14, 2005 at 1:13 am)
One Week of Google Maps
John Resig is posting a series of articles titled One Week of Google Maps already in part 1 and part 2. In the first part he w
Ralph Whitbeck (August 16, 2005 at 8:39 am)
Pretty cool John…I actually started working with Google Maps API on sunday…I am trying to use the animation part of the API to create detailed walkthrough directions from exit 46 to my house in Henrietta. I’ll share it when I am finished.
Tran Nguyen (August 20, 2005 at 10:53 pm)
this series is awesome. I ran into your blog after a search on RIT website. I was planning to implement this API for myself too, but didnt have a chance to start yet. You give me a great motivation.
Jef Poskanzer (August 23, 2005 at 1:11 am)
Click-to-zoom is a nice little tweak, thanks!
John Resig (August 23, 2005 at 1:16 am)
Jef You should check out Part 7 – I implemented a ‘middle mouse wheel to zoom’ feature – it’s very slick.
The Nixon (August 24, 2005 at 7:24 pm)
I’m building a google.maps Geoblog from my adventures with my GPS in hand. I’ve never geocached, I think its cool, but I want to have a day, week, month, year, etc log over most of the places I go. I don’t travel as much as I used to but I though it would be an interesting ‘life’ project. I’m still in the early stages. Cheers!
ã€Uzlog】 (August 26, 2005 at 6:07 am)
Google Maps API ツールã®é–‹ç™ºï¼‹ã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£é–‹è¨
éžå¸¸ã«ã™ã°ã‚‰ã—ã„機能開発をã•ã‚ŒãŸä¾‹ãŒã‚ã£ãŸã®ã§ã€ä¹…ã—ã¶ã‚Šã«Google Maps…
Michael Benedict (August 28, 2005 at 1:34 am)
Thanks for these great writeups… I am creating a website where I would like the pins to be exactly lined up with satellite photos so I combined this tutorial and the double click tutorial to create a tool to obtain this: http://www.zosima.org/gaddress
Very cool stuff, thanks!!!
John Resig (August 28, 2005 at 10:22 am)
Michael Looking good! Let me know how your project turns out in the end.
Ralph Whitbeck (November 17, 2005 at 10:43 pm)
I found that your Perl Script geocoder isn’t as good as the one you link to…it’s not as precise.
Web 2.0 Technologies (April 18, 2006 at 3:04 pm)
Rails, Geocoding, and Google Maps
This is a simple example to demonstrate how to display a Google Map using Ruby on Rails, including utilizing a geocoding web service to translate addresses to geocodes. Why the lookup web service? The Google Maps API doesn’t just let you map an addres…
health insurance quotes (December 12, 2006 at 2:51 pm)
health insurance quotes
Bradford advisability intimately promotion nucleic putters.retirement assonance health insurance california http://healthinsurancecalifornia.infoxd.com/
alex (February 14, 2007 at 9:10 am)
123123
carl (February 14, 2007 at 10:27 am)
123123
carl (February 14, 2007 at 10:27 am)
123123
Parry (April 11, 2007 at 6:50 pm)
i
yeon (July 11, 2007 at 3:24 am)
hi
yeon (July 11, 2007 at 3:42 am)
ddfasdf