ITPub博客

首页 > IT职业 > IT职场 > openlayers根据坐标在地图上划区域

openlayers根据坐标在地图上划区域

IT职场 作者:R-B 时间:2021-09-09 10:12:44 0 删除 编辑


    var styles = {      'Polygon': [new ol.style.Style({        stroke: new ol.style.Stroke({          color: '#ff3100',          lineDash: [0],          width: 1        }),        fill: new ol.style.Fill({          color: 'rgba(0, 0, 255, 0.1)'        })      })],    };    var styleFunction = function(feature) {      console.log(feature)      return styles[feature.getGeometry().getType()];    };    var geojsonObject = {      'type': 'FeatureCollection',      'crs': {        'type': 'name',        'properties': {          'name': 'EPSG:3857'        }      },      'features': [        {        //区域          'type': 'Feature',          'geometry': {            'type': 'Polygon',            'coordinates': [              [                .........              ]            ]          }        },      ]    };    var vectorSource = new ol.source.Vector({      features: (new ol.format.GeoJSON()).readFeatures(geojsonObject)    });    var vectorLayer = new ol.layer.Vector({      source: vectorSource,      style: styleFunction,    });

详细源码
官方源码注释

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4560/viewspace-2818265/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: CGO编程
请登录后发表评论 登录
全部评论

注册时间:2019-09-03

  • 博文量
    183
  • 访问量
    10146