我试图整合OpenStreetMap到一个反应原生的项目.但是我找不到任何库或任何与他们github帐户中的本地反应相关的东西(下面给出的链接).
https://github.com/openstreetmap
我能找到与这些主题相关的唯一内容是以下链接,其中没有正确的答案.
但是,一个人都表示,mapbox使用openstreet map他们的source.The mapbox建议将其集成到一个好办法react-native项目(如下链接).
https://github.com/mapbox/react-native-mapbox-gl
有没有一种方法可以集成openstreet map到一个react-native项目中,或者他们还没有为它创建适当的支持.
是否可以?
这告诉我它是,但不知道它为什么定义和 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,这是 …