【问题标题】:How do I decrease the size of Icon in openlayers 3, i am using bing maps如何减小 openlayers 3 中图标的大小,我正在使用 bing 地图
【发布时间】:2015-03-05 21:25:10
【问题描述】:

这是我的代码:

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);

我也尝试过使用锚点,但我无法减小大小,请帮助

【问题讨论】:

    标签: openlayers-3


    【解决方案1】:

    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
      })
    });
    

    【讨论】:

    • 注:这是一个奇异值,而不是 x/y 单独缩放。确实需要 x/y 缩放才能对某些任务有用。
    • 看起来仍然没有办法使用 imgSize 进行缩放而不是裁剪。 github.com/openlayers/openlayers/issues/2720
    猜你喜欢
    • 2015-03-15
    • 1970-01-01
    • 2015-05-27
    • 1970-01-01
    • 1970-01-01
    • 2018-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多