S
S
Serdji2015-11-13 09:57:43
JavaScript
Serdji, 2015-11-13 09:57:43

Google maps how to make zoom only within a radius of 8 markers?

Friends, please tell me how to make autozoom only 8 markers on the map. I have about 20 markers on my map so far, auto zoom works on all of them. That is, depending on how much they spread out, the map is zoomed. But the task was set to do so, depending on where the client is located, to zoom only on the 8 nearest markers out of N markers on the map. Navigation is also set so that where the client is located is shown.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Николай, 2015-11-13
@healqq

Варианта проще чем самому находить ближайшие 8 маркеров и затем ставить bound карте я не вижу.

N
nozzy, 2015-11-13
@nozzy

На PHP и MySQL, не проверял:

//где находится клиент
$lat = клиент latitude;
$lng = клиент longitude;
//sql-запрос
SELECT
    ROUND(
    6371  * ACOS(SIN( $lat *PI()/180 ) * SIN( $lat *PI()/180 )
        + COS( $lat *PI()/180 ) * COS( $lat *PI()/180 )  *  COS( ($lng*PI()/180) - ($lng*PI()/180) )   ) 
        , 1)  AS distance,
    latitude,
    longitude
FROM
your_table
ORDER BY distance ASC   
LIMIT 8
;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question