Skip to content

Instantly share code, notes, and snippets.

@nicwolff
Created October 21, 2014 15:27
Show Gist options
  • Select an option

  • Save nicwolff/c3d451308880bc3a0aa0 to your computer and use it in GitHub Desktop.

Select an option

Save nicwolff/c3d451308880bc3a0aa0 to your computer and use it in GitHub Desktop.
https://en.wikipedia.org/wiki/Special:MyPage/vector.js to go directly to Google Maps from lat/long links
var gmaps = "//www.google.com/maps/preview#!q=";
function coordsToGmaps(){
var anchors = document.getElementsByClassName('external');
var i = anchors.length;
while ( i-- ) {
var a = anchors[i];
if ( a.href.match( /geohack/ ) ) {
var geodec = a.querySelectorAll('.geo-dec');
var latlong = geodec[0].textContent;
a.href=gmaps+latlong;
}
}
}
window.onload = function() {
coordsToGmaps();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment