Created
January 17, 2013 19:21
-
-
Save alfrekjv/4558785 to your computer and use it in GitHub Desktop.
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
var map = null, | |
latitude = null, | |
longitude = null, | |
infoWindow = null; | |
function useDefaultLocation() { | |
latitude = 31.8391; | |
longitude = -106.5631; | |
} | |
function initialize() { | |
var myOptions = { | |
mapTypeId:google.maps.MapTypeId.ROADMAP, | |
disableDefaultUI: false | |
}; | |
map = new google.maps.Map(document.getElementById("map"), myOptions); | |
latlng = new google.maps.LatLng(latitude, longitude); | |
map.setCenter(latlng); | |
map.setZoom(9); | |
} | |
jQuery(document).ready(function ($) { | |
initialize(); | |
// check if the geolocation object is supported, if so get position | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(function (position) { | |
latitude = position.coords.latitude; | |
longitude = position.coords.longitude; | |
placeSpotsOnMap(); | |
}, function (e) { | |
console.log('geolocation failed'); | |
useDefaultLocation(); | |
}); | |
} else { | |
// browser don't support geo. | |
useDefaultLocation(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment