Stephan, at the moment I have not access to the code because it's used only for an application at work. But I will describe the steps to keep in mind for pmapper and dynamic layers.
There are 2 parts to consider: 1) The dynamic layers have to be initilized, ie. defined with all their properties. This has just to be done once when you want to add one or more layers. And it has of course to be repeated if you want to add other ones. 2) Once the layers have been initialized and are referenced for p.mapper, you have to add them to the map all the time you want to do something with them, ie. for every new map image creation or for queries. to 1) --------------- The script I attached has a function called 'dyn_initPMLayerGroups()'. This function has to be completely adapted to your application. Dynamic layers can have nearly indefinite compositions that I don't see a generic way of doing this. Typically one starts with a database query or user input that provides the necessary parameters. For easier definition I typically use an existing layer as template, so I do not have to define all the properties by hand, just the ones that differ from dynamic layer to another (think about a layer with 10 classes and all the colors etc., would be quite tedious to code this all via Mapscript). One can of course also create dynamic layers based on different templates at the same time. The pre-defined layer definitions are saved in the $_SESSION['dynLayerList'] as well as the names of them in $_SESSION['allGroups']. The call at the end of this function $this->dyn_addLayersToMap($dynLayerList); adds the layers to the map. When referencing a layer list as argument these list is taken, otherwise the same function with argument 'false' is used in step 2) (see below). For each layer definition in this 'dynLayerList' a call is made to 'dyn_createMSlayer()' to actually create each single layer and add it to the map. You can see that this function uses the template layer specified in 'dyn_initPMLayerGroups()'. At the end of the 'dyn_initPMLayerGroups()' the initialization of groups ('new Init_groups') is called again in order to reference all these dynamic layers in the session var 'grouplist' for further use in p.mapper. In order to have a way to distinguish between static layers and dynamic layers the static ones are also additionally once referenced in 'allGroups0' in initmap.php like $_SESSION["allGroups0"] = $allGroups; The layers for templates should have set the status to 'OFF' and should not be referenced in allGroups in config.ini if they are only templates for dynamic layers. One could probably also define a second map file just for the dynamic layers, but I don't know if one can transfer the layer definition from one map to another. to 2) --------------- once dynamic layers are initialized they have to be added to the map every time the map image is created or the map is queried. In map.php there is already the function 'pmap_addCustomLayers()' where one needs to add $dyn = new DynLayer($this->map); $res = $dyn->dyn_addLayersToMap(false); You will have to do the same for the queries. So add this call also in query.php in function 'Query($map)', I hope this is sufficient, otherwise you have to investigate further. Printing should already be covered by map.php because the printing uses the 'PMap' class. The dynamic layers are added at the end of the map, so they are drawn on top of the existing static layers. I used also always the call 'dyn_moveStaticLayersDown()' in order to change the layer orders and to move the static layers down in the map file structure, that means they are displayed *on top* of the dynamic layers. A slightly different approach instead of 2) would be to initialize the layers like in 1), but then write everything to a temp map file (using eg. the session var as file name) and then reference this file as the map file in the session. This way you could more or less completely drop setp 2) because the used map file has always the dynamically created layers in it. I normally try to avoid working too much with temp files if it does not have real benefits. But you could think about that too. I hope this helps a bit. If you succeed you could also write a description for this in the FAQ on the Wiki... Armin Stephan Holl wrote: > Hello Armin, > > On Thu, 08 Jun 2006 16:32:58 +0200 "Armin Burger" > <armin.burger at gmx.net> wrote: > >> Stefan >> >> I attached a sample script to add dynamic layers. You will then have >> to add in map.php (and probably all other scripts where the layers >> are used, like query etc.) the function (it's already in map.php, but >> empty): >> >> function pmap_addCustomLayers() >> { >> $dyn = new DynLayer($this->map); >> $res = $dyn->dyn_addLayersToMap(false); >> } >> >> It means: once the layers have to be initiated and added to >> 'grouplist' session var and then all the time added to the map where >> required. Maybe one could also put this into the setGroups() >> function. Please see if you can work with this short description. >> There are some comments in the attached file as well. > > Wow, what fast reply. Thanks you! I quickly browsed through the file > dynlayer.php and it looks good. I already did it half way through my > way, but I think it is cleaner to use your script. > > Anyway, I do not really understand what I need to call to add a layer > with your script. > Can you provide a short snippet where how to use this? > > TIA > > Stephan > > > >> Armin >> >> >>> Dear pmapper-users, >>> >>> I would like to add dynamic layers to my pmapper2-app (code from >>> 05.06.2006 zipfile). >>> >>> After inspecting the session-vars I *think* I need to add it an >>> array containing information about the new layer to >>> $_SESSION[grouplist]. >>> >>> I tried this but the TOC did not update accordingly. >>> >>> Can someone provide some tipps where to start looking for the needed >>> changes to display the new maplayer? >>> >>> THanks in advance. >>> >>> Best >>> Stephan >>> >>> _______________________________________________ >>> Pmapper-users mailing list >>> Pmapper-users at faunalia.it >>> http://faunalia.it/cgi-bin/mailman/listinfo/pmapper-users > > >