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,
});
openlayers根据坐标在地图上划区域
原创文章标签 openlayers 地图上划区域 文章分类 JavaScript 前端开发
©著作权归作者所有:来自51CTO博客作者lb沫的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
python抓取经纬度信息
爬取城市经纬度信息
ci 结果集 返回结果