Skip to content

Instantly share code, notes, and snippets.

@dievardump
Created July 19, 2013 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dievardump/6042052 to your computer and use it in GitHub Desktop.
Save dievardump/6042052 to your computer and use it in GitHub Desktop.
gmap SO user
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