简体   繁体   中英

Know markers viewed in a google maps and show info about markers what I see in the screen

I have a map and I've created markers:

var marker2 = new Marker({position: new google.maps.LatLng(36.7064, -3.45751),map: map,title: 'HOST_Id: 2 GREENHOUSE_ID:2'});
var marker4 = new Marker({position: new google.maps.LatLng(36.7714, -3.53834),map: map,title: 'HOST_Id: 4 GREENHOUSE_ID:4'});
var marker5 = new Marker({position: new google.maps.LatLng(36.7222, -3.467),map: map,title: 'HOST_Id: 5 GREENHOUSE_ID:5'});
var marker6 = new Marker({position: new google.maps.LatLng(36.7591, -3.15559),map: map,title: 'HOST_Id: 6 GREENHOUSE_ID:6'});

and I want to know what markers are being viewed, for instance, if you move or pann/zoom into the map, I've one or other markers watching, and I want to know what are the markers that I see in my screen.-

Thanks!

You can check via

map.getBounds().contains(marker.getPosition());

if your marker is currently visible. (Contains returns true or false depending on the visibility).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM