Skip to content Skip to sidebar Skip to footer

Adjust Leaflet Popup To Table Size In Angular Leaflet

I have a popup for a layer on the Leaflet map and a popup appears when you click on a point on the map. The popup should display a table with the data for that specific layer. Howe

Solution 1:

You can pre-calculate the total width of the columns and then use that value as a minWidth for the popupOptions:

constcolumnsWidth: number = columns.length * 80// assuming each column width is 80pxconst popupOptions = {
   className: "popup",
   minWidth: columnsWidth // use the calculated width
   ...
};

L.popup(popupOptions)

For this to work, you should assign a fixed width to the columns (using inline styling here just for example purposes):

<table>
    ...
    <td *ngFor="let col of columns"style="width: 80px">
        {{columnDetails[columns]}}
    </td>
    ...
</table>

It will enable Leaflet to render the popup layout properly and position the pin correctly on the map.

Reference: the Leaflet documentation

Post a Comment for "Adjust Leaflet Popup To Table Size In Angular Leaflet"