我的模板中有这段代码,希望标记会与文本“ 1SSMMMS” 一起出现,但是我在市场上根本看不到任何文本
var iconStyle = new ol.style.Style({
image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
anchor: [0.5, 46],
text: "1SSMMMS",
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
src: '../../../map_marker.png'
}))
});
startMarker = new ol.Feature({
geometry: new ol.geom.Point(ol.proj.transform([lng, lat], 'EPSG:4326', 'EPSG:3857')),
name: 'The icon',
population: 4000,
rainfall: 500
});
startMarker.setStyle(iconStyle);
答案 0 :(得分:0)
您需要创建text
属性(有关默认值,请参见doc)
text: new ol.style.Text({
font: '11px Calibri,sans-serif',
text: "1SSMMMS",
fill: fill
})