openlayers根據(jù)坐標(biāo)在地圖上劃區(qū)域
標(biāo)簽:
JavaScript
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, });
详细源码
官方源码注释
點(diǎn)擊查看更多內(nèi)容
為 TA 點(diǎn)贊
評(píng)論
評(píng)論
共同學(xué)習(xí),寫下你的評(píng)論
評(píng)論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦