Geographic Information Systems Asked by spj_uk on March 10, 2021
I have an icon that 4px by 4px and I use it as a marker. However I want to display it larger than 4×4, lets say 40px x 40px for example. Here is my code
var iconStyle = new ol.style.Style({
image: new ol.style.Icon(({
size: [40, 40],
offset: [-20, -20],
//anchor: [0.5, 1],
src: "/images/historymarker.png",
opacity: 1,
id: num + "_" + x
}))
});
marker.setStyle(iconStyle);
However the icons comes out as it original size, Is there a way to resize it? I thought that size would have done it.
You can use scale
:
var iconStyle = new ol.style.Style({
image: new ol.style.Icon(({
scale: 10,
offset: [-20, -20],
//anchor: [0.5, 1],
src: "/images/historymarker.png",
opacity: 1,
id: num + "_" + x
}))
});
marker.setStyle(iconStyle);
Correct answer by geocodezip on March 10, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP