Leaflet / Leaflet.VectorGrid

Display gridded vector data (sliced GeoJSON or protobuf vector tiles) in Leaflet 1.0.0
598 stars 194 forks source link

Read Geojson of a protobuf layer #176

Closed Zahma closed 6 years ago

Zahma commented 6 years ago

Hello, I'm wondering if there is anyway to retrive the geojson coordinates of a protobuf polygon. as in L.Layers in leaflet, there is a method called .toGeoJSON().

thank you

IvanSanchez commented 6 years ago

Hi, great to hear that you find Leaflet useful!

However, this issue tracker is used for reporting bugs and discussing new features. For questions on using Leaflet, please use gis.stackexchange.com or stackoverflow.

If you are really sure that this is a bug in leaflet, or a feature request, please change the wording to make it look like a bug report.

chwahab commented 2 years ago

var gridLayer = L.vectorGrid.protobuf("http://localhost/tileserver/grid/{z}/{x}/{y}.pbf", {


                musafa_grid: (properties, zoom) =>{
                    return {
                        weight: 4,
                        color: '#cf52d3',
                        dashArray: '2, 6',
                        fillOpacity: 0.7
                    }
                }
            },
            getFeatureId: (f) => {
                return f.properties.id;
            },
            maxNativeZoom: 20,
            minZoom: 18,
            interactive: true,
            rendererFactory: L.canvas.tile,
            pane: 'overlayPane'
        }).on('click', (e) => {
            var coords= [];
            var zoom = this.map.getZoom();
            e.layer._parts[0].forEach((p) => {
                coords.push(map.layerPointToLatLng(p));
            });
            L.polygon([coords], {color: 'red'}).addTo(map);
        }).addTo(map);```
        But it did generate polygon at different location