我已经通过了几个不同的例子,并且似乎没有任何工作。我试图用GeoJSON作为源在地图上绘制一个点。这是我目前有的:将geojson图层添加到开放图层3
var staticGeo = new ol.source.GeoJSON(({
object: {
type: 'Feature Collection',
crs: {
type: 'name',
properties: {name: 'EPSG:4326'}
},
features: [{
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [0,0]
}
}]
},
projection: 'EPSG:3857'
}));
var vectorSource = new ol.source.Vector({
source: staticGeo
});
var vectorLayer = new ol.layer.Vector({
source: vectorSource,
style: new ol.style.Style({
fill: new ol.style.Fill({
color: 'rgba(255,255,255,0.2)'
}),
stroke: new ol.style.Stroke({
color: 'blue',
width: 1
})
})
})
this.map.addLayer(vectorLayer);
this.map引用正在工作的ol.Map对象。这整体看起来像很多代码做一些应该看似微不足道(也许我做错了什么?)。
您能够使用最新的OL 3版本吗? –
使用OL 3.4.0,如果我使用3.9.0,此代码是否工作? @JonatasWalker – user1200387