Google Native中的Google Map Javascript API

沙里

是否可以在不完全依赖浏览器DOM的情况下使用javascript api来呈现地图,因为react-native使用View我觉得可以以某种方式使用api,通过传递到全局窗口使api可用的方法也可以使用访存来实现,但我不知道如何启动回调。如果有人知道如何工作,请分享一些想法

<script async defer
     src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
</script>
安德烈斯·纳尔维兹

提到的googlemaps节点模块@sunilp仅为您提供静态地图,无需依靠lib即可轻松构建静态地图,只需搜索google maps api静态地图即可(没有足够的声誉来发布两个以上的链接)。

对于Android,您可以使用:https : //github.com/teamrota/react-native-gmaps

对于iOS,有此功能,但请注意,它仍在进行中(数月未更新):https : //github.com/peterprokop/ReactNativeGoogleMaps

环顾四周,如果您搜索iOS的文档,那么今天最好的(受支持的)iOS赌注是使用React Native自己的MapView。然后,您可以获取对Google Maps API服务的数据调用,然后通过其界面填充MapView。确保您输入密钥并在网址中使用https,否则该服务将拒绝您的呼叫:

fetch(
    'https://maps.googleapis.com/maps/api/directions/json?origin=41.13694,-73.359778&destination=41.13546,-73.35997&mode=driver&sensor=true&key=[YOUR_KEY]'
)
.then(
    (response) => response.text()
)
.then(
    (responseText) => {
        console.log(responseText);
    }
)
.catch(
    (error) => {
        console.warn(error);
    }
);
`

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章