staticmaps icon indicating copy to clipboard operation
staticmaps copied to clipboard

marker height and width not working

Open lambdaxyzt opened this issue 1 year ago • 4 comments

marker height and width option does not take effect in final result no matter how I tweak values !

lambdaxyzt avatar Sep 15 '24 05:09 lambdaxyzt

Please provide some examples or test cases.

StephanGeorg avatar Sep 16 '24 08:09 StephanGeorg

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 image

lambdaxyzt avatar Sep 19 '24 08:09 lambdaxyzt

can someone take a look at example ? tnx .

lambdaxyzt avatar Oct 04 '24 00:10 lambdaxyzt

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

enkatsu avatar Mar 18 '25 16:03 enkatsu