Created
July 19, 2013 20:18
-
-
Save dievardump/6042052 to your computer and use it in GitHub Desktop.
gmap SO user
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
if (navigator.geolocation) { | |
function allowed(position) { | |
initialise(true, position); | |
} | |
function refused() { | |
initialise(false); | |
} | |
function initialize(preserveViewport, position) { | |
var mapOptions = { | |
zoom: 8, | |
mapTypeId: google.maps.MapTypeId.ROADMAP | |
}; | |
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); | |
var kmlLayer = new google.maps.KmlLayer("https://maps.google.ca/maps/ms?ie=UTF8&msa=0&output=kml&msid=210000746142049190989.0004ce14b7a8e95167602", { | |
map: map, | |
preserveViewport: true | |
}); | |
if (position) { | |
var pos = new google.maps.LatLng(position.coords.latitude, | |
position.coords.longitude); | |
map.setCenter(pos); | |
} | |
} | |
google.maps.event.addDomListener(window, 'load', function () { | |
navigator.geolocation.getCurrentPosition(allowed, refused); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment