When a marker is clicked and if it is not on the current visible area, I'm want to do something.
I'm trying with this but it's doing it wrong cause its considering markers I cannot see inside the area. Can't figure out what's wrong here. Thanks!
var marker_is_visible = this.map.getEx开发者_StackOverflow中文版tent().containsLonLat (new OpenLayers.LonLat(marker.x, marker.y))
if (!marker_is_visible) {
// Reset view
}
Actually, there's a standard function onScreen()
for this purpose; check it out here.
Think, your marker.x
and marker.y
are not latitude and longitude but coordinates of map position of marker. Try to check x < 0 || y < 0 || x > mapWidth || y > mapHeight
精彩评论