0

For a project I need to generate previews of polygons that we store in the backend. A polygon typically has this format: [lat,long]

const polygon = [
    [
        4.329064,
        51.276626
    ],
    [
        4.330755,
        51.276416
    ],
    [
        4.329064,
        51.276626
    ]
]

Screenshot mockup

Polygons

I already found out that I can calculate the center of a polygon with polygon.getBounds().getCenter(); and center the map view there, but I rather not load a new Leaflet map for each and every polygon that is stored in the project :)

Are there easier ways to get a map tile as .PNG for example and reference this in my Angular template or do I really have to render a separate map everytime?

Florestan Korp
  • 662
  • 2
  • 12
  • 24
  • 1
    Too broad. Are these previews to be generated in the backend or in the frontend? Are the centroids/bboxes available in the backend? If your question is "is there an easier way of doing X?", the answer is probably "yes, but it depends on the constraints of your system". – IvanSanchez Oct 22 '21 at 14:10

1 Answers1

0

I found a library that let's me export images of Leaflet maps, which I will store as preview for each polygon.

https://github.com/mapbox/leaflet-image

Florestan Korp
  • 662
  • 2
  • 12
  • 24