基于openlayer4画区域


<html>
  <head>
    <title>画区域title>
    
    
        
<script src="js/openlayers/v4.3.3-dist/ol.js">script>

<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>

你可能感兴趣的:(openlayer4)