[英]Openlayers 3 performance markers
I have an Openlayers3 map with a lot of markers and I would like to handle it more efficiently. 我有一个带有很多标记的Openlayers3地图,我想更有效地处理它。
I saw there was a cluster method on the last version of Openlayers and I would like to use the same thing on the third version : http://openlayers.org/dev/examples/strategy-cluster.html 我看到在Openlayers的最后一个版本中有一个集群方法,并且我想在第三个版本中使用相同的方法: http : //openlayers.org/dev/examples/strategy-cluster.html
Do I have to use vectors ? 我必须使用向量吗?
Here is my current code : 这是我当前的代码:
$.getJSON( "http://localhost/folder/address.json", function(data){
for(var k in data) {
var companyCity = data[k].city;
var companyName = data[k].company;
var companyLocation = data[k].address;
var companyLat = data[k].lat;
var companyLng = data[k].lng;
var companyPosition = transform([companyLng,companyLat]);
var elt = $('<p title="'+ companyName +': '+ companyLocation +', '+ companyCity +'"></p>').css({
"width": '5px',
"height": '5px',
"border-radius": '50%',
"background-color": '#E64411',
"opacity" : '.5'
});
var marker = new ol.Overlay({
map: map,
position: companyPosition,
element: elt
});
}
});
Someone has already done it ? 有人已经做过吗?
The cluster strategy does rely on having the markers added to a layer. 集群策略确实依赖于将标记添加到图层。 Is there a strong reason not to do this? 是否有充分的理由不这样做? If you were able to have the address.json stored as geoJSON, it is far more "automatic" to use a layer. 如果您能够将address.json存储为geoJSON,则使用图层会更加“自动”。
If there are strong reasons to not use a layer, you could grab the filter strategy code and customize it to work without a layer. 如果有很强的理由不使用图层,则可以获取过滤器策略代码并对其进行自定义以使其不使用图层。 Looking at OpenLayers.Strategy.Cluster on GitHub , it looks like you would simply need to manually set features to the array of features you have created and then call cluster() at appropriate times. 在GitHub上查看OpenLayers.Strategy.Cluster ,看起来您只需要手动将功能设置为已创建的功能数组,然后在适当的时候调用cluster()即可。
我知道这篇文章很旧,但是现在有一个Clustering示例 。
As of of 14.11.2013 clustering was not yet available in OpenLayers 3 . 截至2013年11月14 日 ,OpenLayers 3中尚未提供群集。 https://groups.google.com/forum/#!topic/ol3-dev/UDjoZSX3Wx4 https://groups.google.com/forum/#!topic/ol3-dev/UDjoZSX3Wx4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.