add layer as first param to base OpenLayers.Feature class. Redo createMarker() and add createPopup(). Redo famous WFS loop so that now it just creates features (according to the feature class passed in) and stores those features in an array. update tests
git-svn-id: http://svn.openlayers.org/trunk/openlayers@407 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -6,7 +6,10 @@ OpenLayers.Feature.prototype= {
|
||||
|
||||
/** @type OpenLayers.Events */
|
||||
events:null,
|
||||
|
||||
|
||||
/** @type OpenLayers.Layer */
|
||||
layer: null,
|
||||
|
||||
/** @type String */
|
||||
id: null,
|
||||
|
||||
@@ -16,59 +19,79 @@ OpenLayers.Feature.prototype= {
|
||||
/** @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(id, lonlat, data) {
|
||||
initialize: function(layer, id, lonlat, data) {
|
||||
this.layer = layer;
|
||||
this.id = id;
|
||||
this.lonlat = lonlat;
|
||||
this.data = data;
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
destroy: function() {
|
||||
this.layer = null;
|
||||
},
|
||||
|
||||
|
||||
createMarker: function(layer) {
|
||||
if (this.lonlat && this.data.iconURL
|
||||
&& this.data.iconW
|
||||
&& this.data.iconH) {
|
||||
var size = new OpenLayers.Size(this.data.iconW, this.data.iconH);
|
||||
var icon = new OpenLayers.Icon(this.data.iconURL, size);
|
||||
var marker = new OpenLayers.Marker(this.lonlat,icon);
|
||||
if (this.title) {
|
||||
var popup = new OpenLayers.Popup(this.latlon,
|
||||
this.getContentHTML());
|
||||
marker.events.register('click', this, popup.open());
|
||||
}
|
||||
this.marker = marker;
|
||||
layer.addMarker(marker);
|
||||
/**
|
||||
*
|
||||
*/
|
||||
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);
|
||||
|
||||
this.icon = new OpenLayers.Icon(imgURL, imgSize);
|
||||
|
||||
this.marker = new OpenLayers.Marker(this.lonlat,
|
||||
this.icon);
|
||||
}
|
||||
},
|
||||
|
||||
/** html content based on feature information
|
||||
*
|
||||
* ret(str):
|
||||
*/
|
||||
getContentHTML:function() {
|
||||
|
||||
var contentHTML = "";
|
||||
|
||||
contentHTML += "<div style='margin: 0.25em'>"
|
||||
|
||||
contentHTML += "<div style='height: 1.5em; overflow: hidden'>"
|
||||
contentHTML += "<span style='font-size: 1.2em; font-weight: bold'>"
|
||||
contentHTML += this.data.title;
|
||||
contentHTML += "</span>"
|
||||
contentHTML += "</div>"
|
||||
|
||||
contentHTML += "</div>"
|
||||
/**
|
||||
*
|
||||
*/
|
||||
createPopup: function() {
|
||||
|
||||
return contentHTML;
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user