Leaflet / Leaflet/Leaflet.VectorGrid

Styling points/circles differently from Polygons

Open
#280 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
676
Forks
202
PR merge metrics
No merged PRs in 30d

Description

Hi there,

I'm loading a protobuf layer of objects containing both polygons and points/circles.
At first load, points/circles are not displayed when creating the vectorGrid using:

vectorGrid = L.vectorGrid.protobuf("https://url/{z}/{x}/{y}.pbf", {
rendererFactory: L.svg.tile,
interactive: true,
minZoom: 15,
maxZoom: 19,
getFeatureId: (f) => {
return f.properties.id;
},
vectorTileLayerStyles: {
item: {
weight: 1,
fill: true,
fillColor: "LightBlue",
fillOpacity: 0.4,
color: 'Gray',
opacity: 0.5,
},
},
})

Capture d’écran 2023-02-03 à 11 06 03

But once the element styles are modified when hovering with mouseover/out event, the circles get styled like polygons and do appear on zoom change (not at the moment they are hovered).
Capture d’écran 2023-02-03 à 11 06 17

I use the following code to handle events:

vectorGrid.on('mouseover', function (e) {
var id = e.layer.properties.id
vectorGridParcelles.setFeatureStyle(id, {
weight: 2,
fillColor: '#999999',
fillOpacity: 1,
fill: true,
color: 'Black',
})
})
vectorGrid.on('mouseout', function (e) {
var id = e.layer.properties.idu
vectorGridParcelles.setFeatureStyle(id, {
weight: 1,
fill: true,
fillColor: "LightBlue",
fillOpacity: 0.4,
color: 'Gray',
opacity: 0.5,
})
})

I read the document which talks about having different set of L.Path options but I can't make it work.
Is there a way to handle that and not display points/circles?

Thanks a lot!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how L.vectorGrid.protobuf applies vectorTileLayerStyles with the SVG renderer, then compare that path with setFeatureStyle calls from the mouseover and mouseout handlers. Confirm how point/circle features are rendered initially and after style changes; done means their visibility and styling no longer depend on hovering or zooming.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.