OpenLayers 3 Resize a feature -
i using openlayers 3 , openstreetmap application. i've managed draw circle vectors on map draw markers, problem have circles have same size when zooming in , out. how can change size of vectors according resolution ?
here vector definition:
var dealersource = new ol.source.vector(); function dealerstyle(feature) { var style = new ol.style.style({ image: new ol.style.circle({ radius: 6, stroke: new ol.style.stroke({ color: 'white', width: 2 }), anchor: [1.5, 1.5], fill: new ol.style.fill({ color: 'green' }) }) }); return [style]; }
you can change size of circle depending on zoom level ( if that's want )
var dealersource = new ol.source.vector(); function dealerstyle(feature) { var style = new ol.style.style({ image: new ol.style.circle({ radius: map.getview().getzoom(), stroke: new ol.style.stroke({ color: 'white', width: 2 }), anchor: [1.5, 1.5], fill: new ol.style.fill({ color: 'green' }) }) }); return [style]; }
getzoom() returns zoom level of map number can either use or transformation on suit desired size of circle.
note above bigger zoom level bigger circle drawn, inverse can replace value by:
yourmaxzoomlevel - map.getview().getzoom()
you can use getresolution() returns number too
Comments
Post a Comment