我有一个页面显示 vector layer 从 kml file 导入(基本上像sundials example) . 它运行得非常好,既可以使用固定策略,也可以同时使用固定策略和CLUSTER策略 .
我想创建 hybrid display ,而 "clusters of 1 feature" 将与 <Style><IconStyle><Icon><href>img/arrowRed.png
下的KML文件中包含的原始 custom icon 一起显示 .
现在, if i use cluster strategy, clusters of 1 (feature) are displayed using the default icon (黄盘) .
我宁愿不使用任何非标准openlayers的插件或库 . any suggestions?
在使用集群的原始javascript代码的一部分下面(删除集群策略声明 new OpenLayers.Strategy.Cluster()
并显示自定义图标):
var urlKMLClient = 'KMLClientsAll.kml';
var layerKMLClient = new OpenLayers.Layer.Vector("Clients", {
strategies: [new OpenLayers.Strategy.Fixed(), new OpenLayers.Strategy.Cluster(), refresh],
protocol: new OpenLayers.Protocol.HTTP({
url: urlKMLClient,
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true,
maxDepth: 2
})
})
});
请参阅下面的客户端自定义图标(绿色标记)让位于群集默认图标(黄色磁盘)
2 回答
使用:
new OpenLayers.Strategy.Cluster({threshold:2})
这允许它们不在群集中的thad孤立点 .(是在GIS论坛中重复同一问题的答案)
在this GIS question找到了解决方案:
将集群策略更改为超过1.上述代码将变为: