Google maps: how to find if there are any markers inside the map

I have divided the display of my google map into part numbers. Now I want to find out if any markers inside / any cell are marked as particles.

Any help?

Further explanation:

I have a map border on

map.getBounds();

and then further divide it by the number of substrates.

I also put markers as

map.addOverlay(markerObject);

Now I want to find out if from the cells (which I got by dividing the map by borders) it contains any markers or not.

I divided all map borders into subgraph numbers

+3
source share
3 answers

. get_position(). , , , , .
PS. it, .


, :

var sub_bounds = new Array();
// here you've pushed into an array the sub bounds
for ( var i = 0; i<sub_bounds.length; ++i)
{
    for ( var j = 0; j < markers.length; ++j)
    {
       var lat = markers[j].get_position( ).lat;
       var lng = markers[j].get_position( ).lng;
       if ( sub_bounds[i].sw.lat<lat && lat<sub_bounds[i].ne.lat &&
            sub_bounds[i].sw.lng<lng && lng<sub_bounds[i].ne.lng)
       // marker within cell, do whatever you need to do
    }
}
0

:

- - sub_bounds? 10 .

. ( (marker.lat/10), (marker.lng/10))

- .

(40, -78) (4,7), .. [ "4 ~ 7" ]

: (4, -7), [ "4 ~ -7" ]

40 50 -70 -80 lng.

GLatLngBounds , , , , .

0
0

Source: https://habr.com/ru/post/1709362/


All Articles