[OpenLayers-Dev] Feature.Data - iconUrl and size is ignored
Michelle Richardson
michelle.richardson2 at baesystems.com
Tue Sep 30 07:32:01 EDT 2008
Hiya
I am dynamically creating layers with features using data from a web
service. I am following one of the openlayers examples and everything works
great (the layers are created with markers that have popups) except for one
thing - the icon url and size data that I pass to the feature is ignored and
it uses the default red kite shape.
I have stepped through the javascript as it's running and the url and sizes
are corrrect. What am I doing wrong? My code is below:
function addMarker(geoMarker, markers)
{
var ll, popupClass, popupContentHTML;
//anchored bubble popup small contents autosize closebox
ll = new OpenLayers.LonLat(geoMarker.Longitude, geoMarker.Latitude);
popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {'autoSize':
true});
popupContentHTML = geoMarker.PopupContent;
var layer = {};
var iconURL = geoMarker.IconUrl;
var iconSize = new OpenLayers.Size(geoMarker.IconWidth,
geoMarker.IconHeight);
var data = { iconURL: iconURL, iconSize: iconSize, 'overflow':'auto' };
//data now has correct values
var feature = new OpenLayers.Feature(layer, ll, data);
feature.closeBox = true;
feature.popupClass = popupClass;
feature.data.popupContentHTML = "<h2>"+geoMarker.Name + "</h2>" +
popupContentHTML;
feature.data.overflow = "auto";
//feature.data.iconURL = iconURL;
var featureMarker = feature.createMarker(); //despite data being set,
uses defaults
var markerClick = function (evt)
{
if (this.popup == null)
{
this.popup = this.createPopup(this.closeBox);
map.addPopup(this.popup);
this.popup.show();
}
else
{
this.popup.toggle();
}
currentPopup = this.popup;
OpenLayers.Event.stop(evt);
};
featureMarker.events.register("mousedown", feature, markerClick);
markers.addMarker(featureMarker);
}
--
View this message in context: http://www.nabble.com/Feature.Data---iconUrl-and-size-is-ignored-tp19740309p19740309.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.
More information about the Dev
mailing list