How to create a closer search for units with google api

0

I need to mount a search that the person selects the state and on the map appear the units closer, as in the image, how do? I do not know where to start:

    
asked by anonymous 08.01.2018 / 13:51

1 answer

0

You can use the Google Places Library :

var map;
var service;
var infowindow;

function initialize() {
  var pyrmont = new google.maps.LatLng(-33.8665433,151.1956316);

  map = new google.maps.Map(document.getElementById('map'), {
      center: pyrmont,
      zoom: 15
    });

  var request = {
    location: pyrmont,
    radius: '500', //Ditância máxima em todas direlções a partir da Longitude e Latitude informados
    types: ['store'] //Que tipos de lugares deve mostrar
  };

  service = new google.maps.places.PlacesService(map);
  service.nearbySearch(request, callback);
}

function callback(results, status) {
  if (status == google.maps.places.PlacesServiceStatus.OK) {
    for (var i = 0; i < results.length; i++) {
      var place = results[i];
      createMarker(results[i]);
    }
  }
}

It is very complete and you can make multiple filters as maximum distance, organize items by proximity, among others I recommend you read the documentation

    
13.04.2018 / 03:10