我试着在铯地球仪上添加wms层,以便在android应用中显示。我使用的是 翩翩 插件v0.3.21,geoserver v2.15.1和铯v1.69。
我在真实设备和仿真器中得到了这个错误和警告。
ElibEGL (23338): validate_display:255 error 3008 (EGL_BAD_DISPLAY)Wcr_media(23338): Requires BLUETOOTH permissionWVideoCapabilities(23338): Unrecognized profile 2130706: Videoavc未识别的配置文件2130706433WAudioCapabilities(23338): Unsupported mime audioalacWAudioCapabilities(23338): Unsupported mime audioalac。Unsupported mime audiodsdWVideoCapabilities(23338): 不支持的哑剧。 Unsupported mime videodivx311WVideoCapabilities(23338): 不支持的mime。不支持的mime videodivx4WVideoCapabilities(23338): 不支持的mime videomp4。不支持的mime videomp4v-esdpIVideoCapabilities(23338)。videomp4v-esIflutter(23338): 不支持配置文件4。在FLUTTER中打开html文件(针对铯) WebviewIflutter(23338): flutter测试 webviewIchromium(23338): [INFO:CONSOLE(1)] "在 "WebMapServiceImageryProvider "中发生错误。Failed to obtain image tile X: 0 Y: 0 Level: 0.", source: https:/cesium.comdownloadscesiumjsreleases1.68BuildCesiumCesium.js。 (1)Ichromium(23338)。[INFO:CONSOLE(1)]......在 "WebMapServiceImageryProvider "中发生错误。Failed to obtain image tile X: 3 Y: 1 Level: 1.", source: https:/cesium.comdownloadscesiumjsreleases1.68BuildCesiumCesium.js。 (1)
这里是源码
铯.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="https://cesium.com/downloads/cesiumjs/releases/1.69/Build/Cesium/Cesium.js"></script>
<link href="https://cesium.com/downloads/cesiumjs/releases/1.69/Build/Cesium/Widgets/widgets.css"
rel="stylesheet">
</head>
<body>
<div id="cesiumContainer" style="width: 100%; height:300px"></div>
<script>
var widget = new Cesium.CesiumWidget('cesiumContainer');
var url='http://localhost:8080/geoserver/wms/'; //Geoserver URL
var layers = widget.scene.globe.imageryLayers;
layers.removeAll();
layers.addImageryProvider(new Cesium.WebMapServiceImageryProvider({
url : url,
layers: 'workspace:layer_name'
}));
</script>
</body>
</html>
主飞镖
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
void main() => runApp(MaterialApp(home: LocalHtmlPage()));
class LocalHtmlPage extends StatefulWidget {
@override
_OpenHTMLPageState createState() => _OpenHTMLPageState();
}
class _OpenHTMLPageState extends State<LocalHtmlPage> {
WebViewController _webViewController;
String filePath = 'assets/cesium.html';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Cesium Example')),
body: WebView(
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_webViewController = webViewController;
_loadHtmlFromAssets();
},
onPageStarted: (url) {
//Invoked when a page starts loading.
print('Open html file (for cesium) in FLUTTER Webview');
EasyLoading.show(status: 'loading...');
},
onPageFinished: (url) {
print('flutter test webview');
EasyLoading.dismiss(animation: false);
},
));
}
_loadHtmlFromAssets() async {
String fileHtmlContents = await rootBundle.loadString(filePath);
_webViewController.loadUrl(Uri.dataFromString(fileHtmlContents,
mimeType: 'text/html', encoding: Encoding.getByName('utf-8'))
.toString());
}
}
pubspec.yaml
cupertino_icons: ^0.1.3
webview_flutter: ^0.3.21
flutter_easyloading: ^1.1.4
easy_web_view: ^1.2.0
我可以试着把你的代码放到Cesium Sandcastle中,看看是否能用。
这里有一个Cesium Sandcastle显示本地GeoServer地图的例子。
如果铯沙堡失败。你必须在GeoServer中启用CORS。. 进入GeoServer的webapps/geoserver/WEB-INF/web.xml,取消所有CORS部分的注释,然后重新启动GeoServer。https:/docs.geoserver.orglatestenuserproductioncontainer.html#enable-cors。