1 /* Copyright (c) 2006 MetaCarta, Inc., published under the BSD license.
2 * See http://svn.openlayers.org/trunk/openlayers/license.txt for the full
3 * text of the license. */
7 OpenLayers.Feature = Class.create();
8 OpenLayers.Feature.prototype= {
10 /** @type OpenLayers.Events */
13 /** @type OpenLayers.Layer */
19 /** @type OpenLayers.LonLat */
25 /** @type OpenLayers.Marker */
28 /** @type OpenLayers.Popup */
34 * @param {OpenLayers.Layer} layer
36 * @param {OpenLayers.LonLat} lonlat
37 * @param {Object} data
39 initialize: function(layer, lonlat, data, id) {
42 this.data = (data != null) ? data : new Object();
43 this.id = (id ? id : 'f' + Math.random());
51 //remove the popup from the map
52 if ((this.layer != null) && (this.layer.map != null)) {
53 if (this.popup != null) {
54 this.layer.map.removePopup(this.popup);
63 if (this.marker != null) {
64 this.marker.destroy();
67 if (this.popup != null) {
75 * @returns A Marker Object created from the 'lonlat' and 'icon' properties
76 * set in this.data. If no 'lonlat' is set, returns null. If no
77 * 'icon' is set, OpenLayers.Marker() will load the default image
78 * @type OpenLayers.Marker
80 createMarker: function() {
84 if (this.lonlat != null) {
85 this.marker = new OpenLayers.Marker(this.lonlat, this.data.icon);
93 createPopup: function() {
95 if (this.lonlat != null) {
97 var id = this.id + "_popup";
98 var anchor = (this.marker) ? this.marker.icon : null;
100 this.popup = new OpenLayers.Popup.AnchoredBubble(id,
103 this.data.popupContentHTML,
109 CLASS_NAME: "OpenLayers.Feature"