[英]How can i create static marker in OpenLayers 3?
我在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'
})
})
})
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.