我正在使用OpenLayers开发一个应用程序。
在加载过程中,我正在运行应用程序,一切都很顺利。但是,群集上显示每个群集上的犯罪数量的标签不会显示。
以下是群集的代码,其中地图正在正常加载。
this.addCrimesToMap = function (){
// Create a vector layers
var vector = new OpenLayers.Layer.Vector("Features", {
renderers: ['Canvas','SVG'],
strategies: [
new OpenLayers.Strategy.AnimatedCluster({
distance: 45,
animationMethod: OpenLayers.Easing.Expo.easeOut,
animationDuration: 20
})
],
styleMap: new OpenLayers.StyleMap({
'default': {
graphicWidth: 25,
graphicHeight: 25,
label: "",
fontColor: "black",
fontSize: "12px",
fontFamily: "Arial",
fontWeight: "bold",
labelAlign: "c", //"l" - left, "r" - right, "c" - center , "m" - midle, "t" - top, "b" - bottom
labelXOffset: "15",
labelYOffset: "0",
labelOutlineColor: "white",
labelOutlineWidth: 3,
externalGraphic: "common/images/map/event_small.png",
display: "yes"
}
})
//styleMap: new OpenLayers.StyleMap(style)
});
map.addLayer(vector);
// Create some random features
var features = [];
for (var i=0; i< 5000; i++) {
var lon = Math.random() * (34.81-34.75) + 34.75;
var lat = Math.random() * (31.28-31.21) + 31.21;
var lonlat = new OpenLayers.LonLat(lon, lat);
lonlat.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
var point = new OpenLayers.Geometry.Point(lonlat.lon, lonlat.lat);
var f = new OpenLayers.Feature.Vector(point);
features.push(f);
}
vector.addFeatures(features);
};
如果我没有使用styleMap,我只能看到没有标签的群集。
我做错了什么?