Location API Maps javaScripts [closed]

-1

I have an application that pulls data from the database and adds it to the map, but I wanted you to only display places that are 20km from my current location, how do I do that using geolocation?

    
asked by anonymous 10.08.2018 / 23:44

1 answer

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
?>    
    
11.08.2018 / 03:38