staticmaps icon indicating copy to clipboard operation
staticmaps copied to clipboard

Allow resizing marker

Open mohd-akram opened this issue 3 years ago • 4 comments

I'm using the map.addMarker() method and was surprised to find that the width and height parameters are for specifying the image's dimensions, instead of the desired size. It might make more sense to get that information directly from the image's metadata, and have the width and height parameters specify the desired output size on the map.

mohd-akram avatar Jun 14 '21 10:06 mohd-akram

Hi @mohd-akram.

Yeah, sounds reasonable. Unfortunately I currently have no resources to work on that topic. Do you have and could you write a PR? Would be awesome.

StephanGeorg avatar Jun 15 '21 07:06 StephanGeorg

Look at #73 @mohd-akram If you like, you can test them already. I need to implement tests, before the merge request is ready

swarnat avatar Aug 02 '22 17:08 swarnat

I would urge to fetch the width and height automatically using sharp - there's no reason for the user to specify them since that data is in the image, and simply use the existing width and height parameters for resizing.

mohd-akram avatar Aug 02 '22 17:08 mohd-akram

The linked pull request now also is able to recognize the marker image size, when not set. Currently I think only the offset must recalculated. But OpenSource time is over, so I will do it later.

I also tried to remove the additional needed time, by reuse the sharp instance for metadata, resize and composite. For some reason the sharp library cannot composite with an instance of itself. But to convert a Buffer into sharp instance probably takes less time. I will check this with some tests.

swarnat avatar Aug 03 '22 15:08 swarnat

#73

StephanGeorg avatar Mar 14 '23 08:03 StephanGeorg

Took a while but finally added. Thank you very much @swarnat for all your work.

StephanGeorg avatar Mar 14 '23 08:03 StephanGeorg