我正在使用openlayers进行测试,我不知道如何在地图中显示包含Point的source.Vector。当我从'url'获取geojson时它工作正常但是没有这种方式。 (应出现蓝色圆圈,但不显示任何内容)
var geojsonObject = new ol.Feature ({
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
self.coords[0].latitude,
self.coords[1].longitude
]
}
}
]
});
var source = new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(geojsonObject)
});
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
title: 'Global Imagery',
source: new ol.source.TileWMS({
url: 'http://demo.opengeo.org/geoserver/wms',
params: {LAYERS: 'nasa:bluemarble', VERSION: '1.1.1'}
})
}),
new ol.layer.Vector({
title: 'Location',
source: source,
style: new ol.style.Style({
image: new ol.style.Circle({
radius: 5,
fill: new ol.style.Fill({
color: '#0000FF'
}),
stroke: new ol.style.Stroke({
color: '#000000'
})
})
})
})
],
view: new ol.View({
projection: 'EPSG:4326',
center: [0, 0],
zoom: 1
})
});
问题出在哪里?风格可能没有很好实现? 提前谢谢!
我遵循了此示例的部分内容:http://openlayers.org/en/latest/examples/geojson.html