[GIS] How to set up the layer order with Google Maps API

google mapsjavascript

I'm developing a web mapping site (using google maps api 3.0 and javascript) that combines wms layers and ground overlays (uploaded rasters) that are displayed on top of google maps. The software is working well except that I'm having problems controlling the draw order of the layers. I would like to have the wms layer (the NRCS soils layer) displayed on top of the custom raster images, with the google maps as the base layer. Currently, the wms layer displays as expected on top of the google maps layer, but is covered by the raster layer. The question is: does the google maps api allow control of the order that layers are displayed (in my case the vector layer on top of raster layer on top of google maps)? I have tried setting the zindex of the display order, but that has not worked (but I could easily be missing something).

Best Answer

how i order it. use

insertAt

first i create layer in object like this.

layer = {}; layer.nrcs_soils= new google.maps.ImageMapType({ getTileUrl: function (coord, zoom) { return getTileWmsUrl(coord, zoom, "nrcs_soils"); }, tileSize: new google.maps.Size(256, 256), opacity: 1, name:'nrcs_soils', alt:{ layer_name:'nrcs_soils' ,order : 0 }, isPng: true });

after that i create simple function add layer to map. add_layer = function(layer_name){ //-- get order from object layer var order_layer =layer[layer_name].alt.order; map.overlayMapTypes.insertAt(order_layer ,layer[layer_name]); }

just call this function for add and order layer from your setting on your object layer. add_layer("nrcs_soils");


or use splice

concept like this.

array = [ 'My', 'name', 'Ruthe' ];

array.splice(1,0,"sur");

console.log('array : '+array); //array : My,sur,name,Ruthe