Created
October 22, 2010 16:41
-
-
Save eikes/640922 to your computer and use it in GitHub Desktop.
Switch google maps to openstreetmap and vice versa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ | |
if (document.location.href.match(/google/)) { | |
var link = document.getElementById("link").getAttribute("href"); | |
var llzrx = /ll=(\d*\.\d*),(\d*\.\d*).*&z=(\d+)/; | |
var match = llzrx.exec(link); | |
var lat = match[1]; | |
var lon = match[2]; | |
var zoom = match[3]; | |
window.open("http://www.openstreetmap.org/?lat="+lat+"&lon="+lon+"&zoom="+zoom); | |
} | |
if (document.location.href.match(/openstreetmap/)) { | |
var link = document.getElementById("permalinkanchor").getAttribute("href"); | |
var llzrx = /lat=(\d*\.\d*)&lon=(\d*\.\d*).*&zoom=(\d+)/; | |
var match = llzrx.exec(link); | |
var lat = match[1]; | |
var lon = match[2]; | |
var zoom = match[3]; | |
window.open("http://maps.google.com/?ll="+lat+","+lon+"&z="+zoom); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment