Hi,
I am trying to create Openlayers.Feature.Vector objects with externalGraphic, and label. and here's my function to do so.
function createFeatureWithIconAndPopup (vectorlayer,featureTitle, featureId, lon, lat, iconFilePath, iconSize, popupInfo)
I need to change the background color of the label to black, however, the Openlayers.Feature.Vector.style label doesn't seem to support html code. Is there a way to change the background color of a feauture's label? If not and I don't want to use popup or marker to do it , is there another way to do it? (I used to add the text with popup which caused performance issues when there are lot of such features. so I am changing the code now..)
{
// geometry of the location object
var point = new OpenLayers.Geometry.Point(lon, lat);
var iconFeature = new OpenLayers.Feature.Vector(point);
if(featureId!="")
iconFeature.id =featureId;
if(featureTitle=="")
{
iconFeature.style ={
externalGraphic:iconFilePath,
graphicXOffset:-iconSize.w/2,
graphicYOffset:-iconSize.h,
graphicWidth:iconSize.w,
graphicHeight:iconSize.h,
pointRadius:0
}
}
else
{
iconFeature.style ={
externalGraphic:iconFilePath,
graphicXOffset:-iconSize.w/2,
graphicYOffset:-iconSize.h,
graphicWidth:iconSize.w,
graphicHeight:iconSize.h,
label: featureTitle,
labelAlign: 'cb',
pointRadius:0
}
}
iconFeature.attribute = {"description": popupInfo}
vectorlayer.addFeatures(iconFeature);
}
so it's something like the below. underneath the icon, there's the label in white in a black background.
Thanks a lot!
Roson