首页 > 解决方案 > 地理服务器和 OpenLayers

问题描述

<html xmlns="http://www.opengis.net/wfs">

<head>
  <title>Openlayers test</title>
  <script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v6.0.1/build/ol.js"></script>
  <link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v6.0.1/css/ol.css">
  <script src="https://code.jquery.com/jquery-3.4.1.js"></script>
  <style>
    .map {
      height: 500px;
      width: 100%;
    }
  </style>

  <script type="text/javascript">
    $("#document").ready(function() {
      var format = 'image/png';

      var bounds = [185100.3262864739, 939575.001675438,
        830327.599490219, 2583234.181646719
      ];
      var ThuaDat = new ol.layer.Image({
        source: new ol.source.ImageWMS({
          ratio: 1,
          url: 'http://localhost:8080/geoserver/decuong_doan/wms',
          params: {
            'FORMAT': format,
            'VERSION': '1.1.1',
            STYLES: '',
            LAYERS: 'decuong_doan:ho_chi_minh_quan',
          }
        })
      });
      var projection = new ol.proj.Projection({
        code: 'EPSG:3405',
        units: 'm',
        axisOrientation: 'neu'
      });
      var map = new ol.Map({
        target: 'map',
        layers: [
          ThuaDat
        ],
        view: new ol.View({
          projection: projection
        })
      });
      //map.getView().fitExtent(bounds, map.getSize());
      map.getView().fit(bounds, map.getSize());
    });
  </script>
</head>

<body>

  <div id="map" class="map"></div>

</body>

</html>

我正在尝试获取 WebGIS。但是当我编写这段代码时,它并没有在浏览器白色中打开。下面是这段代码。:( 这对我来说真的是一个大问题,所以任何人都可以帮助我,拜托。

这是一个图层预览。所以我想在 WebGIS 中导入这些图层。我得到了这段代码,但它没有运行。

在此处输入图像描述1

标签: javascripthtmlpostgresqlopenlayersgeoserver

解决方案


推荐阅读