如何将 Leaflet.js 与 react-native 一起使用

How to use leaflet.js with react-native(如何将 Leaflet.js 与 react-native 一起使用)

本文介绍了如何将 Leaflet.js 与 react-native 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难用 react-native 设置 Leaflet.js.文档告诉我在我的 html 中添加以下脚本...

I am having a difficult time setting up Leaflet.js with react-native. The documentation tells me to add the following script in my html...

<script src="https://unpkg.com/leaflet@1.0.1/dist/leaflet.js"></script>

但我不确定我是如何使用 react 来做到这一点的.现在我的主页呈现如下...

But I am not sure how I do this using react. Right now my main page is being rendered as follows...

AppRegistry.registerComponent('beacon', () => Home);

而我的 Home 就是...

export default Home = () => {
    return (
        <Provider store={store}>
            <MainMap />
        </Provider>
    );
}

在哪里/如何添加此脚本标记以包含 Leaflet.js?甚至可能吗?是否有其他解决方案?

Where/How do I add this script tag to include Leaflet.js? Is it even possible? Is there perhaps another solution?

我还没有看到任何 react-nativeLeaflet.js 的示例,如果有的话,在 github 上或其他什么地方,我很乐意看看吧.

I haven't seen any examples of react-native and Leaflet.js, if there is one, on github or what not, I'd be happy to see it.

推荐答案

有个项目react-leaflet 通过它你可以使用leaflet.js 和react.

There is a project react-leaflet through which you can use leaflet.js with react.

但目前 不支持 在 react-native 中使用 leaflet.js.有关详细信息,请参阅此问题.

But currently there is no support for using leaflet.js in react-native. See this issue for more info.

这篇关于如何将 Leaflet.js 与 react-native 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何将 Leaflet.js 与 react-native 一起使用

基础教程推荐