public int getLayerPosition ( Layer < ? > layer ) { if ( layer == null ) { return - 1 ; } String layerId = layer . getId ( ) ; if ( layer instanceof RasterLayer ) { for ( int index = 0 ; index < mapInfo . getLayers ( ) . size ( ) ; index ++ ) { if ( mapInfo . getLayers ( ) . get ( index ) . getId ( ) . equals ( layerId ) ) { return index ; } } } else if ( layer instanceof VectorLayer ) { int rasterCount = 0 ; for ( int index = 0 ; index < mapInfo . getLayers ( ) . size ( ) ; index ++ ) { if ( layers . get ( index ) instanceof RasterLayer ) { rasterCount ++ ; } if ( mapInfo . getLayers ( ) . get ( index ) . getId ( ) . equals ( layerId ) ) { return index - rasterCount ; } } } return 0 ; }
Get the position of a certain layer in this map model . Note that for both raster layers and vector layer the count starts at 0! On the map all raster layers always lie behind all vector layers .