0

I am trying to develop a map with Leaflet 1.9.3 and GeoServer 2.22.0. When I preview the GeoServer layer, the labels appears at all zoom levels as expected. But when its added to a Leaflet map, I noticed some specific labels do not show at specific zoom level. On closer inspection I noticed that the labels are positioned at about the edge of the Leaflet tiles. Is there a setting that can ensure that Leaflet shows all labels from GeoServer layer? I have looked at similar questions that suggest various vendor options. Below are the vendor options I used in GeoServer. The problem seems to be from the Leaflet maps.

label-conflict-resolution: false;
label-fit-goodness:0.3;
label-partials: false;
mark-label-obstacle: false;
label-max-displacement: 1000;
3
  • I dont think that the problems are the same. I stated in my question that I can see all the labels in the geoserver layer preview. But the label problem occurs when i add the layer to the leaflet map. Also the various vendor options do not help in resolving the problem.
    – mapperx
    Jan 31 at 13:27
  • In GeoServer preview the map isn't tiled, is the WMS layer in Leaflet tiled? if so what if you don't tile the WMS layer in Leaflet?
    – nmtoken
    Feb 2 at 17:51
  • Ok, did not realize. Tried different settings but did not get it. Still going through the documentation and searching through similar questions.
    – mapperx
    Feb 2 at 18:00

1 Answer 1

0

The behavior you're observing could be due to Leaflet's default behavior of only displaying tiles that fit completely within the map's viewport. When the label falls at the edge of the tile, it might not be visible when the tile is displayed in the map.

To ensure that the labels are displayed, you can try setting the noWrap option to true in the TileLayer configuration. This tells Leaflet to display all tiles, even if they extend beyond the edge of the map.

Here's an example:

L.tileLayer('http://yourgeoserver/geoserver/gwc/service/tms/1.0.0/layername@EPSG:4326@png8', {
  maxZoom: 19,
  tms: true,
  noWrap: true
}).addTo(map);

You can also try adjusting the buffer option to ensure that a larger area around the label is included in the tile. The default value for this option is 128, but you can increase it if needed.

1
  • I tried the options and it did not help.
    – mapperx
    Feb 16 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.