是否可以?
这告诉我它是,但不知道它为什么定义和 API 密钥。
但我无法让它与react-map-glStaticMap 类一起使用。我可以从该类中看到的属性只是mapStyle采用标准的 Mapbox 矢量切片路径/名称。它需要一个对象吗?我的代码没有给我错误或显示我请求的图块。
<DeckGL>
<StaticMap
mapStyle= {{
"version": 7,
"sources": {
"simple-tiles": {
"type": "raster",
"tiles":["http://a.tile.openstreetmap.org/{z}/{x}/{y}.png", "http://b.tile.openstreetmap.org/{z}/{x}/{y}.png"],
"tileSize": 256
},
"power": {
"type": "vector",
"tiles": ["http://gpstrails.info/ex/leaflet/power/osm/{z}/{x}/{y}.json"]
}
},
"layers": [{
"id": "simple-tiles",
"type": "raster",
"source": "simple-tiles",
"minzoom": 0,
"maxzoom": 22
},
{
"id": "road",
"source": "power",
"source-layer": "power",
"type": "line",
"layout": {
"line-join": "round",
"line-cap": "round",
},
"paint": {
"line-color": "red",
"line-width": 4,
}
}]
}}/>
</DeckGL>
Run Code Online (Sandbox Code Playgroud)
谢谢
编辑:从正确的答案,并保持在 SO,这是 …