求救!使用geoserver生成的geojson格式,提示Unknown crs name...

其它 · uve1048 · 于 4年前 发布 · 5869 次阅读

使用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里的 (也可能是我改的不对?)

求大神搭救(;д;)

本帖已被设为精华帖!
共收到 4 条回复
uve1048#14年前 0 个赞

呜呜呜,都没人回我的嘛

z954134#24年前 0 个赞

我也碰到同样的问题,不知道楼上是否解决了

cesium_abc#34年前 0 个赞

国内哪里能下到最新的geoJson数据,精细到乡镇的

Rowan_Liu#44年前 1 个赞

@uve1048 #1楼 我原来遇到过这种问题,原因是:我的shp数据转换为geojson数据时,转换的坐标系弄错了,转换成WGS84坐标系,供你参考

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics