• OpenLayer4——面(多边形)


     单独介绍多边形,主要是因为存在多边形组合使用的情况。

    <!DOCTYPE html>
    <html lang="en">
    <head>
       <meta charset="UTF-8">
       <title>Title</title>
       <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
       <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
       <link href="ol/ol.css" rel="stylesheet" type="text/css"/>
       <script type="text/javascript" src="ol/ol.js" charset="utf-8"></script>
    </head>
    <body>
    <div id="map" style=" 100%;height: 100%"></div>
    <script>
       var layerVector = new ol.layer.Vector({
          source: new ol.source.Vector()
       });
    
       var map = new ol.Map({
          layers:[
             new ol.layer.Tile({
                source:new ol.source.OSM(),
             })
             ,layerVector
          ],
          target:'map',
          view:new ol.View({
             center: [12950000, 4860000],
             zoom:7
          })
       });
    
       var iconStyle = new ol.style.Style({
          stroke: new ol.style.Stroke({
             color: '#666666',
              1
          })
       });
    
       var pointFeature2 = new ol.Feature({
          geometry: new ol.geom.Polygon([[[12950000, 4860000],[12950000, 4760000],[12850000, 4760000],[12950000, 4860000]]])
       });
       pointFeature2.setStyle(iconStyle);
    
       layerVector.getSource().addFeature(pointFeature2);
    </script>
    </body>
    </html>

     异或运算

    //异或运算
    var pointFeature = new ol.Feature({
      geometry: new ol.geom.MultiPolygon([
        [
          [
            [12950000, 4860000],[12950000, 4760000],[12850000, 4760000],[12950000, 4860000]
          ]
         , [
            [12900000, 4860000],[12900000, 4760000],[12850000, 4760000],[12900000, 4860000]
          ]
        ]
      ])
    });

     与运算 

    //与运算
    var pointFeature = new ol.Feature({
      geometry: new ol.geom.MultiPolygon([
        [
          [
            [12950000, 4860000],[12950000, 4760000],[12850000, 4760000],[12950000, 4860000]
          ]
        ]
       ,[
           [
             [12900000, 4860000],[12900000, 4760000],[12850000, 4760000],[12900000, 4860000]
           ]
        ]
      ])
    });

  • 相关阅读:
    古老当时兴
    购买代购的产品算违法吗——看空姐代购被判刑有感
    七种方法让你的网站在搜索结果中突围而出(中)
    amf webgame
    游戏开发协议(转)
    array的排序
    用 javascript + actionScript 解决透明的flash在firefox下滚轮失效的问题!(转)
    知乎摘 励志回答
    ie:stagewidth,stageheight的bug
    jsfl bug解决
  • 原文地址:https://www.cnblogs.com/chenss15060100790/p/16050714.html
Copyright © 2020-2023  润新知