0
You can use the Library of Google Places:
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 several filters as maximum distance, organize the items by proximity, among others recommend you read the documentation
You need it to be in PHP or it can be with Javascript?
– flaubert165
could be anyone
– Leandro Marzullo
I did something like that the other day. In the case I did taking the client’s current location, then made the filter based on a given radius, something like: $limit = '1,86411'; // 2,999994244 km $query = '( 6371 * acos( cos( radians('. $lat. ') * cos( radians( addresses.latitude ) * cos( radians( addresses.longitude ) - radians('. $long. ') ) + sin( radians('. $lat. ') ) * sin( radians( addresses.latitude ) )' ), '<=', $limit); From there you can use your imagination and think about how to mount the query
– Flaviano Honorato