[英]Does OpenLayers support y-ordering for marker layers?
I'm working with an OpenLayers map utilizing Marker layers, and I need to ensure that the markers overlap correctly, with markers lower on the y-axis appearing above higher markers. 我正在使用标记层的OpenLayers地图,我需要确保标记正确重叠,y轴上较低的标记出现在较高标记上方。 I assumed I could do this easily with y-ordering, as shown here: 我以为我可以通过y排序轻松做到这一点,如下所示:
http://dev.openlayers.org/examples/ordering.html http://dev.openlayers.org/examples/ordering.html
However, passing in rendererOptions: { yOrdering: true }
doesn't seem to be working, and the example shows it being applied to a Vector layer rather than a Marker layer. 但是,传入rendererOptions: { yOrdering: true }
似乎不起作用,并且该示例显示了将其应用于Vector层而不是Marker层。 Will I have to convert my Marker layers to Vector layers in order to get the benefit of y-ordering, or is there another way to make it work? 为了获得y-ordering的好处,我是否必须将Marker图层转换为Vector图层,还是有其他方法可以使它工作?
Layer.Markers is completely unrelated to Layer.Vector and does not support y-ordering. Layer.Markers与Layer.Vector完全无关,并且不支持y排序。 But you can assign zIndex to the marker icon divs: 但是您可以将zIndex分配给标记图标div:
markerLayer = ...
markerLayer.addMarker (...)
// y-sort markers
markerLayer.markers = markerLayer.markers.sort(function(a,b){
return b.lonlat.lat - a.lonlat.lat;
});
// assign zIndex in y-order
for (var i=0; i<markerLayer.markers.length; i++) {
markerLayer.markers[i].icon.imageDiv.style.zIndex = i;
}
If markers are added, you have to redo this procedure. 如果添加了标记,则必须重新执行此过程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.