staticmaps
staticmaps copied to clipboard
marker height and width not working
marker height and width option does not take effect in final result no matter how I tweak values !
Please provide some examples or test cases.
I use below code , marker width and height is 10 by 10
import StaticMaps from "staticmaps"
import path from "path"
const options = {
width: 600,
height: 400
};
const map = new StaticMaps({width:1000,height:1000});
const marker = {
img: `https://unsplash.com/photos/cxj-8PILRU4/download?ixid=M3wxMjA3fDB8MXxhbGx8NHx8fHx8fDJ8fDE3MjY3MzI4NTl8&force=true&w=640`, // can also be a URL
offsetX: 0,
offsetY: 0,
width: 10,
height: 10,
coord: [13.437524, 52.4945528]
};
map.addMarker(marker);
await map.render();
await map.image.save(path.resolve("./image.png"));
but the result I get
can someone take a look at example ? tnx .
Hello, @lambdaxyzt
I encountered the same issue as you, but I was able to solve it by referring to the test code. It seems that when resizing a marker, you should specify only drawWidth and drawHeight instead of width and height.
I hope this helps, and I wish you success with your work!
const marker = {
img: `https://unsplash.com/photos/cxj-8PILRU4/download?ixid=M3wxMjA3fDB8MXxhbGx8NHx8fHx8fDJ8fDE3MjY3MzI4NTl8&force=true&w=640`, // can also be a URL
offsetX: 0,
offsetY: 0,
drawWidth: 10,
drawHeight: 10,
coord: [13.437524, 52.4945528]
};
map.addMarker(marker);
https://github.com/StephanGeorg/staticmaps/blob/master/test/staticmaps.js#L100