Skip to content

Instantly share code, notes, and snippets.

@vutran0111
Created October 12, 2017 04:32
Show Gist options
  • Select an option

  • Save vutran0111/ffd547f94dfb5fb5e28b2b3fa5d2daa0 to your computer and use it in GitHub Desktop.

Select an option

Save vutran0111/ffd547f94dfb5fb5e28b2b3fa5d2daa0 to your computer and use it in GitHub Desktop.

Revisions

  1. vutran0111 created this gist Oct 12, 2017.
    39 changes: 39 additions & 0 deletions initMap.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    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);
    }