reactjs - React Native 和 WMS

标签 reactjs react-native wms

我正在 React Native 中开发一个移动应用程序,需要使用 Web map 服务。我还没有找到任何允许使用 WMS 并同时进行 native react 的库或框架。在React(Web)中我发现one 。 我的问题是:

您知道是否存在允许我使用 WMS 和 React Native 的库或框架,或者是否有可能将 React(Web)库集成到 React Native 中?

谢谢!

最佳答案

我决定使用的方法如下:

  1. 使用 WebView来自react-native .

  2. 使用openlayers

在您的react-native类的render方法中声明一个变量,其中包含来自openlayers Map的HTML代码: render() { var html = ` <!DOCTYPE html> <html> <head> <title>Simple Map</title> <link rel="stylesheet" href="https://openlayers.org/en/v3.20.0/css/ol.css" type="text/css"> <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x --> <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script> <script src="https://openlayers.org/en/v3.20.0/build/ol.js"></script> </head> <body> <div id="map" class="map"></div> <script> var map = new ol.Map({ layers: [ new ol.layer.Tile({ source: new ol.source.OSM() }) ], target: 'map', view: new ol.View({ center: [0, 0], zoom: 2 }) }); </script> </body> </html> `

然后将此变量传递给 WebView: return ( <View style={styles.container}> <WebView ref={webview => { this.webview = webview; }} source={{html}} onMessage={this.onMessage}/> </View> ); } }

如果您想将react-native端与WebView端进行通信,请查看react-native中的WebView示例。

您可以在 openlayers 示例页面中找到更多示例。

关于reactjs - React Native 和 WMS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38873023/

相关文章:

javascript - 使用 Geoserver 中的 Javascript 动态设置 WMS 图层样式

javascript - React newb 不知道我是否正确导入样式表

node.js - 请求失败,状态码 400

reactjs - @测试库/ react : Clicking outside of component not working

android - 开发服务器返回响应错误码: 500 in react native

typescript - 如何在 typescript + react native 中为主题功能组件正确设置/使用 ref

reactjs - Material UI DatePicker 设置为必需

javascript - 构建高阶组件并将其应用于 redux connect

地理服务器和 WMS

python - 如何在 ipyleaflet 中为 WMS 层设置额外选项?