使用geoserver发布了shp文件 图中第二个,XMQCJCJTY 参数设置如图 使用geoserver自带功能转换成geojson格式,如图
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Use correct character set. -->
<meta charset="utf-8">
<!-- Tell IE to use the latest, best version. -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
<meta name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<title>Hello World!</title>
<script src="../Build/Cesium/Cesium.js"></script>
<style>
@import url(../Build/Cesium/Widgets/widgets.css);
html,
body,
#cesiumContainer {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body>
<div id="cesiumContainer"></div>
<script>
var viewer = new Cesium.Viewer('cesiumContainer');
//Seed the random number generator for repeatable results.
Cesium.Math.setRandomNumberSeed(0);
var promise =
Cesium.GeoJsonDataSource.load('http://localhost:8800/geoserver/ditu/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=ditu:XMQCJCJTY&maxFeatures=50&outputFormat=application/json');
promise.then(function (dataSource) {
viewer.dataSources.add(dataSource);
var entities = dataSource.entities.values;
var colorHash = {};
for (var i = 0; i < entities.length; i++) {
var entity = entities[i];
var name = entity.name;
var color = colorHash[name];
if (!color) {
color = Cesium.Color.fromRandom({
alpha: 1.0
});
colorHash[name] = color;
}
entity.polygon.material = color;
entity.polygon.outline = false;
entity.polygon.extrudedHeight = 5000.0;
}
});
viewer.flyTo(promise);
</script>
</body>
</html>
在我修改网上demo后,反复出现这个错误 我尝试换demo,换地图发布,换坐标系的地图,切换到本地geojson等等方法,都无济于事 甚至于跑到外网,找到一个类似的例子 修改了\Source\DataSources\GeoJsonDataSource.js里的 (也可能是我改的不对?)
求大神搭救(;д;)