我如何在Openlayers 3中减小Icon的大小,我正在使用bing映射 [英] How do I decrease the size of Icon in openlayers 3, i am using bing maps

查看:688
本文介绍了我如何在Openlayers 3中减小Icon的大小,我正在使用bing映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

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

我也尝试过使用锚点,但无法减小尺寸,请帮忙

I have tried using anchor also, but I could not decrease the size, please help

推荐答案

ol.style.Icon 带有一个scale参数,可用于缩放图标.

ol.style.Icon takes a scale parameter that you can use to scale your icon.

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

这篇关于我如何在Openlayers 3中减小Icon的大小,我正在使用bing映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆