Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I decrease the size of Icon in openlayers 3, i am using bing maps

Tags:

openlayers-3

This is my code:

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

like image 537
user1960217 Avatar asked Mar 05 '15 21:03

user1960217


1 Answers

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
  })
});
like image 108
tsauerwein Avatar answered Oct 15 '22 22:10

tsauerwein