0
votes

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. I assumed I could do this easily with y-ordering, as shown here:

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. 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?

1

1 Answers

0
votes

Layer.Markers is completely unrelated to Layer.Vector and does not support y-ordering. But you can assign zIndex to the marker icon divs:

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.