开发者

Checking if a marker is in the current visible area

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜