1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
| polygon () {
let styles = [
new Style({
stroke: new Stroke({
color: '#5a3fc0',
width: 0.5
}),
fill: new Fill({
color: 'rgba(0, 0, 255, 0.1)'
})
}),
new Style({
image: new CircleStyle({
radius: 0.5,
fill: new Fill({
color: 'rgba(0, 0, 255, 0.1)'
})
}),
geometry: function(feature) {
// return the coordinates of the first ring of the polygon
let coordinates = feature.getGeometry().getCoordinates()[0];
return new MultiPoint(coordinates);
}
})
];
let geojsonObject = {
'type': 'FeatureCollection',
'crs': {
'type': 'name',
'properties': {
'name': 'EPSG:3857'
}
},
'features': [{
'type': 'Feature',
'geometry': {
'type': 'Polygon',
'coordinates': [this.resp_isochrone]
}
}
]
};
let source = new VectorSource({
features: (new GeoJSON()).readFeatures(geojsonObject)
});
let layer = new LayerVector({
source: source,
style: styles
});
//console.log(coordinates);
this.map.addLayer(layer);
} |
Partager