admin管理员组文章数量:1221301
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?
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?
Share Improve this question edited Jan 14, 2015 at 12:21 Joel 7,5694 gold badges54 silver badges59 bronze badges asked Oct 28, 2011 at 9:01 kamilkamil 3,5221 gold badge43 silver badges64 bronze badges 3- 1 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 :) – kamil Commented Oct 28, 2011 at 12:44
- Great that you found the solution. :-) Place it as an answer and mark it as solution for other to easily see that it's solved. – Niklas Wulff Commented Oct 31, 2011 at 11:44
- i just couldn't do it earlier cause i cant answer own questions for 8hrs ;) – kamil Commented Oct 31, 2011 at 13:44
1 Answer
Reset to default 19If 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 :)
本文标签: javascriptOpenlayers zIndex for markers and vectorsStack Overflow
版权声明:本文标题:javascript - Openlayers zIndex for markers and vectors - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739361288a2159830.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论