Locate a person and show them on the map

0

I'm in need of help, I hope you can help me. I need, by means of a select, to choose a seller and show their location on the map. I used Javascript Google Maps Api and I managed to show my location on the map but I do not know how to ask a cell phone for its longitude and latitude data to show it on the map. I use the following code but I am not achieving it:

<script>

  function initMap() {
    var map = new google.maps.Map(document.getElementById('map'), {
      center: {lat: -34.603722, lng: -58.381592},
      zoom: 16
    });
    var infoWindow = new google.maps.InfoWindow({map: map});

    // Try HTML5 geolocation.
    if (navigator.geolocation) {
      navigator.geolocation.getCurrentPosition(function(position) {
        var pos = {
          lat: position.coords.latitude,
          lng: position.coords.longitude
        };

        infoWindow.setPosition(pos);
        infoWindow.setContent('Su ubicación.');
        map.setCenter(pos);
      }, function() {
        handleLocationError(true, infoWindow, map.getCenter());
      });
    } else {
      // Browser doesn't support Geolocation
      handleLocationError(false, infoWindow, map.getCenter());
    }
  }

  function handleLocationError(browserHasGeolocation, infoWindow, pos) {
    infoWindow.setPosition(pos);
    infoWindow.setContent(browserHasGeolocation ?
                          'Error: La geolocalizacion falló' :
                          'Error: Tu navegador no soporta geolocalización');
  }
</script>
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AQUIMIKEY&callback=initMap"></script>
    
asked by Sebastian 21.06.2018 в 16:12
source

0 answers