MapScript: index of new layers

Stephen Lime steve.lime at dnr.state.mn.us
Tue Jul 25 12:32:57 EDT 2000


Finally someone noticed. Right now you can't. This is an artifact of the original code that uses
an array of layers rather than a linked list. It's on the "todo" list. It is possible to work around
it as there is nothing that says that you must draw layers in the order that they appear. The
main $map->draw() method assumes this but you can step through the layers in any order
you wish and use $layer->draw() to build up the map. For example you could maintain an
array of layer names in the order they should be drawn:

# load map and add to it (layers, extents, etc...)

@layers = {'county', 'water', 'places', 'roads'};

$img = $map->prepareImage();
foreach $name (@layers) {
  $layer = $map->getLayerByName($name);
  $layer->draw(...);
}
$map->drawLabelCache($img);

Another possiblity is to store 'dummy' layers as placeholders in the main map file and then
edit their definitions instead of starting from scratch. This way the main $map->draw() method
will work since the order was set in the map file.

Steve

Stephen Lime
Internet Applications Analyst

Minnesota DNR
500 Lafayette Road
St. Paul, MN 55155
651-297-2937

>>> "Michael Anderson" <m_anderson14 at hotmail.com> 07/25/00 11:18AM >>>
Hello,

When you add a new layer to a map using MapScript, how can you control the 
new layers index relative to the existing layers in the .map file? The new 
layer is drawing on top and obscuring the rest of the layers.

Mike
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com 





More information about the mapserver-users mailing list