0

我的模板中有这段代码,期望标记会出现文本"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);
4

1 回答 1

0

您需要创建该属性(有关默认值,text请参阅文档)

 text: new ol.style.Text({
         font: '11px Calibri,sans-serif',
         text: "1SSMMMS",
         fill: fill
       })
于 2018-11-01T11:28:04.913 回答