diff --git a/lib/OpenLayers/Marker.js b/lib/OpenLayers/Marker.js index 4a9fa47f3b..318dbc0280 100644 --- a/lib/OpenLayers/Marker.js +++ b/lib/OpenLayers/Marker.js @@ -59,6 +59,24 @@ OpenLayers.Marker.prototype = { } }, + /** + * @returns Whether or not the marker is currently visible on screen. + * @type Boolean + */ + onScreen:function() { + + var screenBounds = OpenLayers.Bounds.fromSize(this.map.getSize()); + + var iconTop = parseInt(this.icon.div.style.top); + var iconLeft = parseInt(this.icon.div.style.left); + var iconBottom = iconTop + parseInt(this.icon.div.style.height); + var iconRight = iconLeft + parseInt(this.icon.div.style.width); + var iconBounds = + new OpenLayers.Bounds(iconLeft, iconBottom, iconRight, iconTop); + + return screenBounds.containsBounds(iconBounds, true); + }, + /** * @param {float} inflate */