Created
October 12, 2017 04:32
-
-
Save vutran0111/ffd547f94dfb5fb5e28b2b3fa5d2daa0 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
function initMap() { | |
map = new google.maps.Map(document.getElementById('map'), { | |
// center: {lat: 42.9456, lng: -122.2}, | |
// center: { lat: 10.7663468, lng: 106.6589143 }, | |
zoom: 14 | |
}); | |
infoWindow = new google.maps.InfoWindow; | |
// Geolocation. | |
if (navigator.geolocation) { | |
navigator.geolocation.getCurrentPosition(function(position) { | |
var pos = { | |
lat: position.coords.latitude, | |
lng: position.coords.longitude | |
}; | |
infoWindow.setPosition(pos); | |
infoWindow.setContent('Location found.'); | |
infoWindow.open(map); | |
map.setCenter(pos); | |
}, function() { | |
handleLocationError(true, infoWindow, map.getCenter()); | |
}); | |
loadMarkers(); | |
setInterval(function(){ | |
console.log("loadMarkers"); | |
loadMarkers(); | |
}, 30000); | |
} else { | |
// Browser doesn't support Geolocation | |
handleLocationError(false, infoWindow, map.getCenter()); | |
} | |
// loadMarkers(); | |
// setInterval(function(){ | |
// console.log("loadMarkers"); | |
// loadMarkers(); | |
// }, 30000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment