Last active
August 29, 2015 14:06
-
-
Save elasticthreads/cd388dbef5f43fa519a5 to your computer and use it in GitHub Desktop.
Javascript bookmarklet you can run when in google maps (on OS X) to look at the same location in Apple Maps (useful for transfer to iOS).
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:var%20y%20=%20document.location.href;if%20(y.indexOf(%27google.com/maps/%27)%3E=0)%20{if(y.indexOf(%27/preview/search/%27)%3E=0){var%20query=y.indexOf(%27/preview/search/%27)+16;query=y.substring(query,y.length);var%20x=%27http://maps.apple.com/?q=%27+query;document.location=x;setTimeout(function()%20{document.location=y;},%20900);}else{var%20llDex=y.indexOf(%27/@%27)+2;var%20len=y.indexOf(%27/data%27);if(len==-1){len=y.length;}if((len%3E0)&&(llDex%3Clen)){var%20loc=y.substring(llDex,len);llDex=loc.lastIndexOf(",");len=loc.length-1;if((llDex%3E0)&&(llDex+1%3Clen)){var%20zoom=loc.substring(llDex+1,len);loc=loc.substring(0,llDex);var%20x=%27http://maps.apple.com/?ll=%27+loc+%27&z=%27+zoom;document.location=x;setTimeout(function()%20{document.location=y;},%20900);}}}} |
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: | |
var y = document.location.href; | |
if (y.indexOf('google.com/maps/') >= 0) { | |
if (y.indexOf('/preview/search/') >= 0) { | |
var query = y.indexOf('/preview/search/') + 16; | |
query = y.substring(query, y.length); | |
var x = 'http://maps.apple.com/?q=' + query; | |
document.location = x; | |
setTimeout(function() { | |
document.location = y; | |
}, 900); | |
} else { | |
var llDex = y.indexOf('/@') + 2; | |
var len = y.indexOf('/data'); | |
if (len == -1) { | |
len = y.length; | |
} | |
if ((len > 0) && (llDex < len)) { | |
var loc = y.substring(llDex, len); | |
llDex = loc.lastIndexOf(","); | |
len = loc.length - 1; | |
if ((llDex > 0) && (llDex + 1 < len)) { | |
var zoom = loc.substring(llDex + 1, len); | |
loc = loc.substring(0, llDex); | |
var x = 'http://maps.apple.com/?ll=' + loc + '&z=' + zoom; | |
document.location = x; | |
setTimeout(function() { | |
document.location = y; | |
}, 900); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment