Last active
December 11, 2015 06:28
-
-
Save dragoonis/4559462 to your computer and use it in GitHub Desktop.
This file contains hidden or 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(10); | |
} | |
jQuery(document).ready(function ($) { | |
// check if the geolocation object is supported, if so get position | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(function (position) { | |
geo = true; | |
latitude = position.coords.latitude; | |
longitude = position.coords.longitude; | |
initialize(); | |
}, function (e) { | |
useDefaultLocation(); | |
initialize(); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment