Google Maps / Live Maps switcher bookmarklet


Google Maps / Live Maps switcher bookmarklet

Published on Sun 07 Sep 2008 12:09 ( 1 year, 12 months ago)
Javascript Google Maps

I wrote a Google Maps / Google Ditu switcher bookmarklet before. Now comes the switcher bookmarklet for Google Maps and Microsoft Live Maps:

code:

javascript: var _cur= ""+window.location; if (_cur.search(/http:\/\/maps.goog/i) !=-1) { var _url = document.getElementById('link'); function gup( name , u) { name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( u );if( results == null )    return ""; else return results[1];} lurl = 'http://maps.live.com/default.aspx?cp=' + gup('ll', _url).replace(/\,/,'~')+'&lvl='+gup('z', _url); window.location=lurl;} else if (_cur.search(/http:\/\/maps.live/i) != -1) { eval('var _xxx ='+ document.getElementById('MapControl_MapControl').value); gurl = "http://maps.google.com/maps?ll=" +_xxx.C.Latitude +","+ _xxx.C.Longitude + "&z=" + _xxx.Z; window.location=gurl;} else { alert('This script only works on maps.live.com or maps.google.com, check http://dev.robertmao.com for update.');}

Please save above as a bookmarklet, and you can switch freely from google maps and live maps!


I only spend half a hour to create it so it may have bug or not work in some scenarios, and it need improve on map mode switch.


Tested on firefox only, should workable in IE.


Related posts:


Search related in web:

Custom Search

RSS Feed

One click subscribe this blog in your google reader!

Be social!


Want to say something here? please sign in



Blog posts link to this page
What are friends tweeting?
Tags cloud
Monthly Archives