Leaflet / Leaflet.VectorGrid

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

I cant display points. I can't change the style points/polygons. #255

Open r4naf opened 3 years ago

r4naf commented 3 years ago

I have only polygons and points in my database. It is in one table and one column. I do not store any more signs (river, house, etc. ... this is not). Polygons are displayed normally. I just need to display the points, with my own style. It's strange why the points are not shown. Also, I cannot change the style for all polygons. I looked at the help. Perhaps I need something much simpler ... Thank you in advance!

<script type="text/javascript"  src="https://unpkg.com/leaflet.vectorgrid@1.2.0"></script>

<script>
var vectorTileStyling = {}
var openmaptilesUrl = "http://192.168.0.57:8080/{z}/{x}/{y}.pbf";
var openMapTilesLayer = L.vectorGrid.protobuf(openmaptilesUrl, {
    vectorTileLayerStyles: vectorTileStyling,
    attribution: '© OpenStreetMap contributors, © MapTiler'
});
...
var overlays = {
    "Vector Tiles": openMapTilesLayer
};
...
L.control.layers(baseLayers, overlays).addTo(mymap);
</script>

SQL on server:

WITH webmercator(envelope) AS (
  SELECT ST_TileEnvelope(15, 20891, 9773)
)
SELECT ST_AsMVT(tile) FROM (
    SELECT osm_id , tile1 FROM (
      SELECT osm_id, ST_AsMVTGeom(poly3857, (SELECT envelope FROM webmercator)) as tile1
      FROM polygon43
    ) a
    where tile1 is not null)
AS tile

DBeaver DBeaver2

r4naf commented 3 years ago
<script>
        var vectorTilePolyOption = {
            rendererFactory: L.canvas.tile,
                vectorTileLayerStyles: {
                    default: function(e) {
                        console.log(e)
                        return{
                            color: '#00F',
                            weight: 1
                        }
                    },
                },
            };

        var openmaptilesUrl = "http://192.168.0.57:8080/{z}/{x}/{y}.pbf";
        var openMapTilesLayer = L.vectorGrid.protobuf(openmaptilesUrl, vectorTilePolyOption);
</script>

Happened! But the points are not shown in any way.