I'm rendering map with OSM and I have some serious problem with setting zIndex for page elements.
Part of JS looks like this:
var userRoute = new OpenLayers.Layer.Vector( "KML", {
sphericalMercator : true,
styleMap: styleMap,
rendererOptions: { zIndexing: true }
} );
var markers = new OpenLayers.Layer.Markers( "Markers", {
sphericalMercator : true,
rendererOptions: { zIndexing: true }
} );
markers.setZIndex( 500 );
userRoute.setZIndex( 200 );
Now while parsing KML file for first element I set
var startFlag = new OpenLayers.Icon( '/start_flag_2.png', new OpenLayers.Size( 23, 22 ) );
markers.addMarker( new OpenLayers.Marker( latlon, startFlag ) )
Same goes for last elem. :
var stopFlag = new OpenLayers.Icon( '/stop_flag_2.png', new OpenLayers.Size( 23, 22 ) );
markers.addMarker( new OpenLayers.Marker( latlon, stopFlag ) )
Setting zIndex is simply ignored by script, any idea why?
If anyone is intrested, you need to specify zIndex AFTER adding layers to map
map.addLayers( [userRoute, markers] );
markers.setZIndex( 1001 );
userRoute.setZIndex( 1000 );
and it works just fine :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With