我需要添加一个图标并在图像的底部添加一个文本。我怎样才能做到这一点 ?
我尝试使用这种样式,但文本呈现在图像中间。
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
projection: ol.proj.get('EPSG:4326')
}),
style: new ol.style.Style({rules: [
new ol.style.Rule({
symbolizers: [
new ol.style.Icon({
url: 'http://127.0.0.1/app/img/imageTest.png',
opacity: 0.75,
width: 12,
height: 12
}),
new ol.style.Text({
color: '#000',
text: ol.expr.parse('i'),
fontFamily: 'Calibri,sans-serif',
fontSize: 12
})
]
})
]})
});
map.addLayer(vector);
var f = new ol.Feature({
'i': 1,
'size': 20
});
f.setGeometry( new ol.geom.Point([lon,lat]) );
var features = new Array();
features.push(f);
vector.addFeatures(features);