基于openlayer4画区域


<!DOCTYPE html>
<html>
  <head>
    <title>画区域</title>
    <!-- <link rel="stylesheet" href="https://openlayers.org/en/v5.1.3/css/ol.css" type="text/css"> -->
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
        <!-- openlayers:地图控件 -->
<script src="js/openlayers/v4.3.3-dist/ol.js"></script>
<!-- openlayers CSS 文件 -->
<link rel="stylesheet" href="js/openlayers/v4.3.3-dist/ol.css" type="text/css" />

  </head>
  <body>
    <div id="map" class="map"></div>
    <script>
      var raster = new ol.layer.Tile({
        source: new ol.source.OSM()
      });

      var wkt = '';// 区域wkt点集

      var format = new ol.format.WKT();

      var feature = format.readFeature(wkt, {
        dataProjection: 'EPSG:4326',
        featureProjection: 'EPSG:4326'
      });

      var vector = new ol.layer.Vector({
        source: new ol.source.Vector({
          features: [feature]
        })
      });

      var map = new ol.Map({
        layers: [raster, vector],
        target: 'map',
        view: new ol.View({
          center: [117.3626, 32.9184],
          // 指定投影使用EPSG:4326
          projection: 'EPSG:4326',
          zoom: 13
        })
      });
    </script>
  </body>
</html>

转载自:https://blog.csdn.net/qq_27186245/article/details/82227315

You may also like...

退出移动版