这是我的代码:
var iconFeature = new ol.Feature({
geometry: new ol.geom.Point(ol.proj.transform([-95.3698,29.7604], 'EPSG:4326' , 'EPSG:3857')),
name: 'Null Island',
});
var iconStyle = new ol.style.Style({
image: new ol.style.Icon({
opacity: 0.75,
src: 'flag.png',
height:10,
width:10,
})
});
iconFeature.setStyle(iconStyle);
我也试过使用锚,但是我无法减小尺寸,请帮助
答案 0 :(得分:16)
ol.style.Icon
会使用scale
参数来缩放图标。
var iconStyle = new ol.style.Style({
image: new ol.style.Icon({
opacity: 0.75,
src: 'flag.png',
// the real size of your icon
size: [10, 10],
// the scale factor
scale: 0.5
})
});