Google Maps / Live Maps switcher bookmarklet
Published on Sun 07 Sep 2008 12:09 ( 1 year, 12 months ago)
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:
- Google Maps / Live Maps switcher bookmarklet
- A page which crash Firefox 3.0
- Notes on learning jQuery
- Learning notes on Javascript class/objects
- JSON vs XML parsing performance
- Top 10 js sites
- The best analytics plugin I ever seen: Geotrack Plugin (2.0.2)
- Google Maps + Google Ditu Mashup
- Get google reader's UID
- Google Maps / Ditu switcher bookmarklet
Search related in web:
Custom Search