git-svn-id: http://svn.openlayers.org/trunk/openlayers@417 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
102 lines
2.4 KiB
JavaScript
102 lines
2.4 KiB
JavaScript
/**
|
|
* @class
|
|
*/
|
|
OpenLayers.Feature = Class.create();
|
|
OpenLayers.Feature.prototype= {
|
|
|
|
/** @type OpenLayers.Events */
|
|
events:null,
|
|
|
|
/** @type OpenLayers.Layer */
|
|
layer: null,
|
|
|
|
/** @type String */
|
|
id: null,
|
|
|
|
/** @type OpenLayers.LonLat */
|
|
lonlat:null,
|
|
|
|
/** @type Object */
|
|
data:null,
|
|
|
|
/** @type OpenLayers.Icon */
|
|
icon: null,
|
|
|
|
/** @type OpenLayers.Marker */
|
|
marker: null,
|
|
|
|
/** @type OpenLayers.Popup */
|
|
popup: null,
|
|
|
|
/**
|
|
* @constructor
|
|
*
|
|
* @param {OpenLayers.Layer} layer
|
|
* @param {String} id
|
|
* @param {OpenLayers.LonLat} lonlat
|
|
* @param {Object} data
|
|
*/
|
|
initialize: function(layer, lonlat, data, id) {
|
|
this.layer = layer;
|
|
this.lonlat = lonlat;
|
|
this.data = data;
|
|
this.id = (id ? id : 'f'+Math.Random());
|
|
},
|
|
|
|
/**
|
|
*
|
|
*/
|
|
destroy: function() {
|
|
this.layer = null;
|
|
},
|
|
|
|
|
|
/**
|
|
*
|
|
*/
|
|
createMarker: function() {
|
|
|
|
var imgLocation = OpenLayers.Util.getImagesLocation();
|
|
|
|
if (this.lonlat != null) {
|
|
|
|
var imgURL = (this.data.iconURL) ? this.data.iconURL
|
|
: imgLocation + "marker.png";
|
|
|
|
var imgSize = (this.data.iconSize) ? this.data.iconSize
|
|
: new OpenLayers.Size(25, 25);
|
|
|
|
var imgOffset = (this.data.iconOffset) ? this.data.iconOffset
|
|
: new OpenLayers.Pixel(0,0);
|
|
|
|
this.icon = new OpenLayers.Icon(imgURL, imgSize, imgOffset);
|
|
|
|
this.marker = new OpenLayers.Marker(this.lonlat,
|
|
this.icon);
|
|
}
|
|
},
|
|
|
|
/**
|
|
*
|
|
*/
|
|
createPopup: function() {
|
|
|
|
if (this.lonlat != null) {
|
|
|
|
if (this.marker) {
|
|
var anchorSize = this.marker.icon.size;
|
|
}
|
|
|
|
this.popup =
|
|
new OpenLayers.Popup.AnchoredBubble(this.id + "_popup",
|
|
this.lonlat,
|
|
this.data.popupSize,
|
|
this.data.popupContentHTML,
|
|
anchorSize);
|
|
}
|
|
|
|
},
|
|
|
|
CLASS_NAME: "OpenLayers.Feature"
|
|
};
|