@@ -67,16 +67,34 @@ OpenLayers.Feature.prototype= {
67
67
this . marker = null ;
68
68
}
69
69
if ( this . popup != null ) {
70
- this . popup . destroy ( ) ;
70
+ this . destroyPopup ( this . popup ) ;
71
71
this . popup = null ;
72
72
}
73
73
} ,
74
74
75
+ /**
76
+ * @returns Whether or not the feature is currently visible on screen
77
+ * (based on its 'lonlat' property)
78
+ * @type Boolean
79
+ */
80
+ onScreen :function ( ) {
81
+
82
+ var onScreen = false ;
83
+ if ( ( this . layer != null ) && ( this . layer . map != null ) ) {
84
+ var screenBounds = this . layer . map . getExtent ( ) ;
85
+ onScreen = screenBounds . containsLonLat ( this . lonlat ) ;
86
+ }
87
+ return onScreen ;
88
+ } ,
89
+
75
90
76
91
/**
77
92
* @returns A Marker Object created from the 'lonlat' and 'icon' properties
78
93
* set in this.data. If no 'lonlat' is set, returns null. If no
79
- * 'icon' is set, OpenLayers.Marker() will load the default image
94
+ * 'icon' is set, OpenLayers.Marker() will load the default image.
95
+ *
96
+ * Note: this.marker is set to return value
97
+ *
80
98
* @type OpenLayers.Marker
81
99
*/
82
100
createMarker : function ( ) {
@@ -89,12 +107,24 @@ OpenLayers.Feature.prototype= {
89
107
return this . marker ;
90
108
} ,
91
109
110
+ /** If user overrides the createMarker() function, s/he should be able
111
+ * to also specify an alternative function for destroying it
112
+ */
92
113
destroyMarker : function ( ) {
93
114
this . marker . destroy ( ) ;
94
115
} ,
95
116
96
117
/**
118
+ * @returns A Popup Object created from the 'lonlat', 'popupSize',
119
+ * and 'popupContentHTML' properties set in this.data. It uses
120
+ * this.marker.icon as default anchor.
121
+ *
122
+ * If no 'lonlat' is set, returns null.
123
+ * If no this.marker has been created, no anchor is sent.
124
+ *
125
+ * Note: this.popup is set to return value
97
126
*
127
+ * @type OpenLayers.Popup.AnchoredBubble
98
128
*/
99
129
createPopup : function ( ) {
100
130
@@ -112,5 +142,13 @@ OpenLayers.Feature.prototype= {
112
142
return this . popup ;
113
143
} ,
114
144
145
+
146
+ /** As with the marker, if user overrides the createPopup() function, s/he
147
+ * should also be able to override the destruction
148
+ */
149
+ destroyPopup : function ( ) {
150
+ this . popup . destroy ( )
151
+ } ,
152
+
115
153
CLASS_NAME : "OpenLayers.Feature"
116
154
} ;
0 commit comments