TransWikia.com

Layer ordering of ST_ASMVT tiles in Leaflet

Geographic Information Systems Asked by Arsh Doda on May 9, 2021

I am generating MVT tiles for multiple layers in Django using the following query:

WITH 
    bounds AS (
            SELECT ST_Segmentize(ST_MakeEnvelope(8247861.100083642, 3551570.082242422, 8252753.069893893, 3556462.052052673, 3857),1222.9924525627866) AS geom, 
                            ST_Segmentize(ST_MakeEnvelope(8247861.100083642, 3551570.082242422, 8252753.069893893, 3556462.052052673, 3857),1222.9924525627866)::box2d AS b2d
    ), 
    f_282 AS (
            SELECT ST_Simplify(ST_AsMVTGeom(ST_Transform(t.geom, 3857), bounds.b2d, 4096, 128, true), 25) AS geom,
            t.id
            FROM g_feat_poly t, bounds
            WHERE ST_Intersects(t.geom, ST_Transform(bounds.geom, 4326)) 
            AND t.shp_id = 282 AND t.deleted = FALSE
            UNION
            SELECT ST_Simplify(ST_AsMVTGeom(ST_Transform(t.m_geom, 3857), bounds.b2d, 4096, 128, true), 25) AS m_geom,
            t.id
            FROM g_feat_poly t, bounds
            WHERE ST_Intersects(t.m_geom, ST_Transform(bounds.geom, 4326)) 
            AND t.shp_id = 282 AND t.deleted = FALSE
    ), 
    f_259 AS (
            .........
    ), 
    f_258 AS (
            .........
    ), 
    f_255 AS (
            .........
    ), 
    f_257 AS (
            .........
    ), 
    sa AS (
            .........
    )
             
    SELECT ST_AsMVT(f_282.*, '282') FROM f_282
        UNION 
    SELECT ST_AsMVT(f_259.*, '259') FROM f_259
        UNION 
    SELECT ST_AsMVT(f_258.*, '258') FROM f_258
        UNION 
    SELECT ST_AsMVT(f_255.*, '255') FROM f_255
        UNION 
    SELECT ST_AsMVT(f_257.*, '257') FROM f_257
        UNION 
    SELECT ST_AsMVT(sa.*, 'sa') FROM sa

and displaying it in Leaflet using vectorgrids with following code:

var url = '..../api/v1/tiles/6/13/5782/3369/?shp=282-POLYGON,259-POLYGON,258-POLYGON,255-POLYGON,257-POLYGON,7-sa'
var featTilesLayer = L.vectorGrid.protobuf(url, {
                interactive: true,
                vectorTileLayerStyles: shpStyle,
                getFeatureId: function(f) {
                    return f.properties.id;
                }

But i am unable to change the order of layers as all the layers are in single vector layer. I tried changing the order in URL and in SQL query.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP