我对javascript和OpenLayers的掌握程度不高,我正在尝试实现一张带有静态标记的地图,该标记指向世界各地的机场。
好吧,我试图搜索我的答案,但我无法解决我的问题。
我已经尝试找到文档或示例,但是每次都行不通。
请问有人可以通过告诉我如何根据数据列表创建标记来帮助我吗?
非常感谢。
(小提琴)
var vectorLayer = new ol.layer.Vector({
source: new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: 'url_of_your_file'
})
});
map.addLayer(vectorLayer);
这样,您可以将GeoJSON文件加载到地图中。
例如,如果您想要一个圆形标记,则可以添加一个ol.layer.Vector
喜欢的样式:
var vectorLayer = new ol.layer.Vector({
source: new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: 'url_of_your_file'
}),
style: new ol.style.Style({
image: new ol.style.Circle({
radius: 10,
fill: new ol.style.Fill({
color: '#ffff00'
})
})
})
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句