Skip to content

Instantly share code, notes, and snippets.

@vutran0111
Created October 12, 2017 04:32
Show Gist options
  • Save vutran0111/ffd547f94dfb5fb5e28b2b3fa5d2daa0 to your computer and use it in GitHub Desktop.
Save vutran0111/ffd547f94dfb5fb5e28b2b3fa5d2daa0 to your computer and use it in GitHub Desktop.
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