Description
I am trying to make an ocean map layer, including bathymetry, from this Esri vector tile service. I am able to style the various bathymetry depths by providing a JavaScript string to the vector_tile_layer_styles
param on the VectorTileLayer
constructor and it works well.
import ipyleaflet
from ipyleaflet import Map, VectorTileLayer
ipyleaflet.__version__
'0.19.2'
world_tiles_url = "https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer/tile/{z}/{y}/{x}.pbf"
jstyle='''{
"Bathymetry": function(properties, zoom){
var color = "blue";
var fill = true;
if(properties._symbol==0){
color = "#d6f4ff";
}
if(properties._symbol==1){
color = "#ccf0ff";
}
if(properties._symbol==2){
color = "#c2ecff";
}
if(properties._symbol==3){
color = "#b8e6ff";
}
if(properties._symbol==4){
color = "#ade0ff";
}
if(properties._symbol==5){
color = "#a3d9ff";
}
return {
color: color,
fill: fill,
opacity: 1,
fillOpacity: 1
}
},
//"Marine area": {"fillOpacity": 1, "color": "#e7f9ff", "fill": true},
}
'''
bathymetry = VectorTileLayer(
url=world_tiles_url,
vector_tile_layer_styles=jstyle,
base=True,
name="Bathymetry Basemap"
)
m = Map(center=[45, -45], zoom=5)
[m.remove(lyr) for lyr in m.layers]
m.add(bathymetry)
m
This looks pretty good!
However, the water areas nearest the coastlines is not filled. This is because the required features are in the "Marine area" layer; when I uncomment the "Marine area" style in my jstyle
above those areas are indeed filled, but the features cover up my bathymetry.
When I look at these vector tiles using Esri's style editor the layers draw in the correct order: https://www.arcgis.com/apps/vtseditor/en/#/7dc6cea0b1764a1f9af2e679f642f0f5/layers
Can I control the layer draw order somehow? From everything I've read, this is controlled in the vector tiles themselves via the zIndex
. In this case I want the Marine area
layer to draw underneath the Bathymetry
layer instead of on top of it.