-1
I have an application where you take the data from the database and add it on the map, I wanted you to display only places up to 20 km away from my current location, how do I do this using geolocation?
-1
I have an application where you take the data from the database and add it on the map, I wanted you to display only places up to 20 km away from my current location, how do I do this using geolocation?
0
<?php
$latitude = -XX.YYYY; //Coloque sua latitude
$longitude = -XX.YYYY;//Coloque sua longitude
$km = 20;//Distância
$query = "
SELECT `cep`, (6371 * acos(cos(radians($latitude)) *
cos(radians(`latitude`)) *
cos(radians(`longitude`) - radians($longitude)) +
sin(radians($latitude)) *
sin(radians(`latitude`))))
AS `distancia`
FROM `tb_enderecos`
HAVING `distancia` < $km
ORDER BY `distancia` ASC
LIMIT 10;"; //Limita registros
?>
Browser other questions tagged php javascript google-maps-api-3
You are not signed in. Login or sign up in order to post.