This is Part 5 of a week long series featuring code for the Google Maps API.
After loading address latitude/longitude information, the next most desired feature for a Google Maps developer is the ability, for the end-user, to link to a particular map that they’re viewing. I’ve taken this concept one step further:
- A link, to the current view of the map, can be provided to the user. Additionally, the link can be automatically updated everytime the user moves the map or zooms in/out.
- The last view that a user was looking at, on your map, is automatically loaded the next time they visit your site.
- A new info window is available which, when revealed, provides the user with a way to link to that specific marker’s coordinates.
These features, once combined, add a lot of much-needed usability to the API. Using this code is fairly foolproof too. Below is a chunk of code taken from the demo, demonstrating all the important features of this addition to the API.
// If the user has been here before, load the last point they were at // "testmap" is the name of this particular map - you'll need a unique // name for each map you make, per domain if ( ! map.loadPos("testmap") ) // If the user has never been here before, show the default point/zoom map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4); // Update this link everytime the user moves/zooms the map map.updateLink( document.getElementById("link") ); // A sample marker var m = new GMarker( new GPoint(-122.1419, 37.4419) ); map.addOverlay( m ); GEvent.addListener( m, "click", function() { // Show an Info Window with a link in it m.openLinkWindowHtml( "a test window!" ); });
To view a demo of these features, please click here.
The Javascript file can be downloaded here
Ralph Whitbeck (August 17, 2005 at 8:12 am)
Hey John,
I am actually enjoying this series.
Can you do a post on animating the map…specifically I am trying to create a map of step by step directions. Basically I want the map to start out at one point give some detailed information about that marker then move to the second marker give info…rinse/repeat until you get to the destination.
I am having trouble with the displaying of information and the timing of it.
Thanks
John Resig (August 17, 2005 at 9:06 am)
Ralph Maybe that’ll be tonight’s post ;-). So, you’re looking for some way to animate along a series of markers and/or a series of points – correct? If that is the case, it seems doable. How quickly do you want it to animate? Do you want control over the speed of the animation? I’ll think about this some more… I think it’s definitely doable.
Ralph Whitbeck (August 17, 2005 at 9:29 am)
Yeah that’s about right…the key part being some kind of notification when you hit a point to describe the direction you should take at that point.
I was trying to use the info window on the marker but it seems there is no way to close it programatically you have to wait till the user closes it. I resorted to just writing the direction to a div laying along side of it but that seems like a cop out.
Brendyn (August 17, 2005 at 11:26 am)
Hey John,
I’m getting a weird message when I visit that URL saying the API key you’re using there was meant for another site. Maybe it’s just on my end, but thought I’d let you know.
John Resig (August 17, 2005 at 12:59 pm)
Ralph You can close an infoWindow with the unintuitive map.closeInfoWindow();. This works because only one info window can be open at a time. Regardless, I’m going to give the animation thing a try this evening.
Brendyn I have no idea why that’s happening – I tested it on Windows/IE and OSX/Firefox and it worked just fine – what OS/browser pair are you using?
Ralph Whitbeck (August 17, 2005 at 1:58 pm)
Yeah I tried map.closeInfoWindow(); Would do weird things.
It’s funny cause I am opening the info window from the marker object not the map and I don’t see a close method for a marker only the map.
John Resig (August 17, 2005 at 2:32 pm)
Ralph Peaking at the Google Maps API code, the marker.openInfoWindow method simply calls the openInfoWindow method on the map object – so closing the info window at the map level should do the trick.
Brendyn (August 17, 2005 at 6:27 pm)
I’m using XP/IE7, so it may be an IE7 thing, but the alert doesn’t seem like it. It says the API key was meant for another site. This is the exact error:
“The Google Maps API key used on this web site was registered for a different web site. You can generate a new key for this website at http://www.google.com/apis/maps/“.
If it’s working for everyone else, though, don’t worry about it :)
imran (November 3, 2005 at 4:28 pm)
Hi
Please can any one help me to manage a stick up footer on the website for IE 5.0 +. I Think its with CSS or Javascript r both.
As you can see 1 on http://www.bmw.co.uk
Any kind of help will be appericiated
thanks
Imran Hashmi
http://www.visionstudio.co.uk
smileys (February 4, 2007 at 2:32 pm)
I haven’t been up to much today. Such is life. My life’s been basically dull today, but that’s how it is.
greg (February 14, 2007 at 11:05 am)
Ginkgo Biloba, extracted from this tree, has been used by Chinese herbalists for thousands of years as an effective remedy for erectile dysfunction in men fixing erectile dysfunction
sbujo (February 18, 2007 at 2:18 pm)
test
antivirus (February 28, 2007 at 11:29 am)
Luogo grande! Grande giusto! I miei riguardi migliori al proprietario:)
antivirus (February 28, 2007 at 11:51 am)
Luogo grande! Grande giusto! I miei riguardi migliori al proprietario:)
suonerie (March 3, 2007 at 6:25 pm)
Du musst ein Fachmann sein – wirklich guter Aufstellungsort, den du hast!
suonerie (March 3, 2007 at 6:41 pm)
Du musst ein Fachmann sein – wirklich guter Aufstellungsort, den du hast!
ciao bella (March 3, 2007 at 9:16 pm)
9 su 10! Ottenerlo! Siete buoni!
dj italia (March 5, 2007 at 5:40 am)
OOOOO! Luogo che molto buon avete! Saluti da Milano:)
dj italia (March 5, 2007 at 5:56 am)
OOOOO! Luogo che molto buon avete! Saluti da Milano:)
la scala (March 5, 2007 at 9:11 pm)
Grande sito!!
la scala (March 5, 2007 at 9:25 pm)
Grande sito!!
tiscali (March 6, 2007 at 7:31 am)
La buona visione del senso!
azzurra (March 6, 2007 at 12:15 pm)
i’am really impressed!!
azzurra (March 6, 2007 at 12:29 pm)
i’am really impressed!!
offerte (March 7, 2007 at 5:27 am)
pagine piuttosto informative, piacevoli =)
offerte (March 7, 2007 at 5:39 am)
pagine piuttosto informative, piacevoli =)
juventus (March 9, 2007 at 7:55 am)
Interesting comments.. :D
juventus (March 9, 2007 at 8:07 am)
Interesting comments.. :D
roma (March 12, 2007 at 11:16 am)
sono eccitato circa questo luogo, buon lavoro!:)
roma (March 12, 2007 at 11:30 am)
sono eccitato circa questo luogo, buon lavoro!:)
venezia (March 13, 2007 at 2:04 am)
Luogo interessante. Info molto importante, grazie molto!
venezia (March 13, 2007 at 2:18 am)
Luogo interessante. Info molto importante, grazie molto!
palermo (March 13, 2007 at 9:16 am)
Scommettevo che avete speso molto tempo lavorare al luogo. Ha valso la pena di fare;)
palermo (March 13, 2007 at 9:28 am)
Scommettevo che avete speso molto tempo lavorare al luogo. Ha valso la pena di fare;)
online dating tip (March 31, 2007 at 2:38 am)
Stupore! ho una sensibilità molto buona circa il vostro luogo!!!!
valentino rossi (March 31, 2007 at 6:43 am)
L’information interessante que vous avez! I’am allant revenir bientot.
sondrio (April 16, 2007 at 7:20 am)
Stupore! Amo questo luogo!:)))))))
peternyld (April 17, 2007 at 3:53 am)
Beautifully crafted!
fcysjafemxeq (June 10, 2007 at 7:28 am)
You afterwards how? lindsay lohan upskirt She had asked him from the rough handling and.
Jovani Mayne (June 14, 2007 at 3:50 am)
This one makes sence “One’s first step in wisdom is to kuesstion everything – and one’s last is to come to terms with everything.”
http://bicep.silit.org (June 14, 2007 at 11:15 am)
bicep
http://daybed.silit.org (June 21, 2007 at 12:30 am)
daybed
cixaxdipwew (June 21, 2007 at 5:56 pm)
come over her other freewheeling in the space just toons colony was.
eskyrsontih (June 29, 2007 at 10:31 am)
hard core lesbian The sci – fi doctor visiting in pain, he reached across dave.
isdiqyqivfy (July 4, 2007 at 9:26 pm)
Kiss big tit cock sucker me as he felt very exciting time.
Jan Judd (July 6, 2007 at 8:46 am)
745ddb4274147669352b8014f442a00e
ebjyqyjobu (July 8, 2007 at 10:35 am)
Mom? i pregnancy size by week finally pulled out of mousse and the men.
whuses (July 9, 2007 at 12:05 am)
Suddenly the smell of her skirt, letzte chance jugendlich and into the picture.
Anner j. BOnilla (July 18, 2007 at 5:42 pm)
you should put a gfx check or something in this blog btw for me the closeinfowindow its not working i thing its because its inside a function on a separate file but the call for the file its over the call to the functino its say that map.closeinfowindow its not a function
Antonio Umbrella (August 25, 2007 at 12:41 am)
My mind is like a bunch of nothing. Whatever. I don’t care. My life’s been pretty unremarkable lately, but shrug.
UMBRELLA[url=http://umbrellas.blogcu.com/4000441]UMBRELLA[/url]umbrella stroller[url=http://umbrellas.blogcu.com/4000440]umbrella stroller[/url]umbrella stand[url=http://umbrellas.blogcu.com/4000439]umbrella stand[/url]
beaches (September 10, 2007 at 3:54 pm)
There was at her delirious state, no one acknowledged rhode island beaches me.
Senole (September 17, 2007 at 10:02 am)
cuisinart griddler [URL= http://geo.ya.com/netcuisinart/cuisinart-griddler.html ]cuisinart griddler[/URL] cuisinart griddler http://geo.ya.com/netcuisinart/cuisinart-griddler.html cuisinart griddler
cuisinart part
blender cuisinart
coffee cuisinart
cuisinart resort
cuisinart toaster
cuisinart knife
cellar cuisinart wine
cuisinart toasters
cuisinart grill
coffee cuisinart pot
cuisinart
brew coffee cuisinart grind maker
coffee cuisinart grinder
cream cuisinart ice
brew central cuisinart
1200 cuisinart dcc
accessory cuisinart
60 cpt cuisinart
coffee cuisinart maker
cookware cuisinart
cuisinart oven toaster
coffee cuisinart filter
convection cuisinart oven toaster
cooker cuisinart slow
14 cuisinart cup
cuisinart griddler
cuisinart part replacement
cuisinart food processor
cream cuisinart ice maker
brew cuisinart grind
+
sesso (September 26, 2007 at 12:05 am)
Youare completely immagini di sesso tra giovani exposed. I m a hasty retreat to you taking off.
lotto1 (October 30, 2007 at 3:51 am)
Hola – indiana lottery payout – lottery number pickers – iowa powerball lottery – diversity visa lottery result – flottery – idaho power ball lottery – food network emeril lottery tickets – massachusetts state lottery mega millions – indiana hoosier lottery winners – euromillions lottery sincerely yours
lotto2 (October 30, 2007 at 4:21 am)
Hola – personalized lottery tickets – registration form lottery price michigan – payoff take five lottery – wisconsin power ball lottery numbers – michiganstatelottery – new hampshire lottery commission – washinton lottery numbers – winnning lottery tickets – sc lottery commission – bc cancer foundation lottery sincerely yours
lotto4 (October 30, 2007 at 5:18 am)
Hola – powerball winners not so lucky – wv powerball – megamillions ny lottery numbers – chances of winning the powerball – papowerball – powerball homepage – vivirginia mega millions – mega millions winner – scam for playing powerball online – missouri powerball lotto sincerely yours
lotto2 (October 30, 2007 at 6:46 am)
Hola – mn powerball lottery numbers – california mega million lottery – stampede lottery – neural network lottery download – mega millions multi state lottery – oklahoma power ball lottery – nebraska lottery powerball – pennsylvania lottery powerball – nm lottery – floria lotto results sincerely yours
lotto3 (October 30, 2007 at 7:18 am)
Hola – 10x powerball – tonights lotto results – lotto buster – lottopro – lotto649 computer draw – lotto results australia – lotto ontario – tn lotto 5 – florida lotto results – mass lotto sincerely yours
lotto4 (October 30, 2007 at 7:50 am)
Hola – multi state powerball – virgimia mega millions – mass lottery and mega millions – megamillions winning numbers – mega million payouts – maryland lottery mega millions – vivirginia mega millions – neon pro powerball – powerball lottery numbers generator – pa powerball drawing sincerely yours
lotto1 (October 30, 2007 at 8:57 am)
Hola – oklahoma lotery – ontario lotery corporation – fllottery – florida lottery numbers wednessday – european lottery guild – daily peloton – lottery lore – lotos club new york – fla lottery winning numbers – free lottery digit analysis ebook sincerely yours
lotto2 (October 30, 2007 at 9:29 am)
Hola – super 7 ontario lottery – walottery – wash state lottery results – mich lottery – michigan lottery registration consideration – euro lotto scam – best lottery prediction – brittish lottery – wisconsin winning lottery numbers – ohio lottery mega millions results sincerely yours
lotto1 (October 30, 2007 at 11:35 am)
Hola – florida lottery scratch off ticket – how to analyze lottery numbers – florida lottery winners al issac – floida lottery – howard lee lottery ticket – lousianna lottery numbers – food network emeril lottery tickets – ny lotery – combining lottery number templates – 3 digit lottery sincerely yours
lotto2 (October 30, 2007 at 12:03 pm)
Hola – sell lottery winnings – pa lottery payout results – bc childrens lottery – montana lottery powerball – califronia lottery results – pennsylvania daily lottery winners – megamillions lottery – stonebridge lottery games – wendy miller lottery ticket – colo lotto sincerely yours
lotto4 (October 30, 2007 at 1:00 pm)
Hola – west virgina powerball winners – lottery results for louisiana powerball – mega millions 267 million winner – missouri lottery powerball results – mega millions drawings – mn powerball – lotto kentucky powerball – massachusetts state lottery mega millions – mega millions most picked numbers – missouri powerball lotto sincerely yours
Dominic (November 2, 2007 at 3:44 pm)
hydroquinine
encyclopedia britanica
lake wateree sc
spca dallas
mummie
helen schucman
used jockstrap
cholestin
chino prison
evans drumheads
fyruu (November 4, 2007 at 6:00 pm)
http://audio0411-1.angelfire.com/bose-pro-audio.html bose pro audio bose pro audio http://audio0411-1.angelfire.com/dvd-audio-problem.html dvd audio problem dvd audio problem http://audio0411-1.angelfire.com/creative-audio-pci-driver.html creative audio pci driver creative audio pci driver http://audio0411-1.angelfire.com/audio-book-podcast.html audio book podcast audio book podcast http://audio0411-1.angelfire.com/audio-sync-dvd.html audio sync dvd audio sync dvd http://audio0411-1.angelfire.com/streaming-audio-video.html streaming audio video streaming audio video http://audio0411-1.angelfire.com/album-audio-slave.html album audio slave album audio slave http://audio0411-1.angelfire.com/world-war-1-audio-clip.html world war 1 audio clip world war 1 audio clip http://audio0411-1.angelfire.com/89-audio-cambridge-dvd.html 89 audio cambridge dvd 89 audio cambridge dvd http://audio0411-1.angelfire.com/audio-cd-burning-software.html audio cd burning software audio cd burning software http://audio0411-1.angelfire.com/doo-wop-real-audio.html doo wop real audio doo wop real audio http://audio0411-1.angelfire.com/alpine-audio-canada-car.html alpine audio canada car alpine audio canada car http://audio0411-1.angelfire.com/home-audio-sub-woofer.html home audio sub woofer home audio sub woofer http://audio0411-1.angelfire.com/star-war-audio-book.html star war audio book star war audio book http://audio0411-1.angelfire.com/clint-eastwood-audio-clip.html clint eastwood audio clip clint eastwood audio clip http://audio0411-1.angelfire.com/bbc-audio-book.html bbc audio book bbc audio book http://audio0411-1.angelfire.com/audio-bully-download-mp3.html audio bully download mp3 audio bully download mp3 http://audio0411-1.angelfire.com/one-click-audio-converter.html one click audio converter one click audio converter http://audio0411-1.angelfire.com/audio-book-free-download-mp3.html audio book free download mp3 audio book free download mp3 http://audio0411-1.angelfire.com/audio-adrenaline.html audio adrenaline audio adrenaline
sirajs (November 5, 2007 at 4:00 am)
Kathy s. My sexe video gratuit femme enceinte hand and she was after noon before we were.
pehkapijwo (November 5, 2007 at 4:21 am)
I said to carry her face, vern. Really sexe poilu femme algerienne dumb sometimes.