尝试在大叶地图上应用覆盖图块

问题描述 投票:0回答:1

我正在尝试使用Python中的“folium”库创建一个html文件,然后使用“Mapillary”api应用覆盖图块,但在应用该层时它没有显示。

奇怪的是,在 QGIS 程序上我得到了这一层: enter image description here

这是我的代码:

生成 html:

`def create_map(): my_map = folium.Map(location=[50, 0], Zoom_start=8)

vector_tile_url = "https://tiles.mapillary.com/maps/vtp/mly1_public/{z}/{x}/{y}?access_token=" + os.getenv(
    "MAPILLARY_API_KEY")

attribution = "Map data &copy; <a href='https://mapillary.com'>Mapillary</a> contributors"

folium.TileLayer(vector_tile_url, name="mapillary", attr=attribution, overlay=True).add_to(my_map)

folium.LayerControl().add_to(my_map)

my_map.save("map_with_vector_tiles.html")

print("Map with vector tiles saved as map_with_vector_tiles.html")`
python qgis folium
1个回答
0
投票

似乎 Mapillary 使用了协议缓冲区。所以,也许您需要一个

VectorGridProtobuf

import os
import folium

m = folium.Map(location=[0,0], zoom_start=2, width="80%", height="70%")

url = (
    "https://tiles.mapillary.com/maps/vtp/"
    "mly1_public/2/{z}/{x}/{y}?access_token={token}"
)

options = {
    "token": os.getenv("MAPILLARY_API_KEY"),
    "vectorTileLayerStyles": {
        "overview": {
            "fill": True,
            "radius": 5,
            "color": "#e87147",
            "opacity": 0.6,
        },
    },
}

pbf = folium.plugins.VectorGridProtobuf(url, "mapillary", options)
pbf.__dict__["overlay"] = True # otherwise, TypeError

pbf.add_to(m)

folium.LayerControl().add_to(m)

NB:随意添加另外两个图层的样式:序列和图像。

输出(

m
在 Jupyter):

© www.soinside.com 2019 - 2024. All rights reserved.