[fusion-users] Show Layer added in MapScript

Paul Spencer pspencer at dmsolutions.ca
Fri Mar 12 08:51:45 EST 2010


You are welcome!  I was pretty sure you had most of it but I wanted the explanation in the wild on the list so that others might learn something new too :)

Your approach should be sound, the whole purpose of having a session copy of the map file is to prevent changes to the original.  As long as you are opening the session copy and saving over the session copy, there are no issues.

Cheers

Paul

On 2010-03-12, at 2:57 AM, Tom van der Putte wrote:

> Hi paul,
> 
> Thanks for the code! I had had almost everything, except the $oMap->save($_SESSION['maps'][$mapName]); part, which turned out to be sort of critical ;). It works now.
> 
> But your explanation about  changing the mapfile structure led me to wondering if my idea is the right way to go.
> 
> I'm trying to create a simple raster querying tool that allows user to show only those portions of a geological depth map that are above or below a certain (user-defined) level, while also retaining the original raster in the TOC. I was planning to do this by (in Mapscript) creating a copy of the relevant raster, and by adding a classification (non-relevant pixels -> transparent) showing the result of the query. 
> 
> But I'd like to be sure that I'm changing only the map for the current user/session, and not for other users who are using the mapserver at that time. Will this do the trick?
> 
> Cheers,
> Tom
> 
> 
> On Thu 11/03/10 16:52 , Paul Spencer pspencer at dmsolutions.ca sent:
> Hi Tom,
> 
> The fusion framework makes a temporary copy of the original map file for use in the current user's session so that it can be manipulated without affecting other users. If you want to change the map file structure in some way, you need to make an ajax call to a server side script and then reload the map on the client side (which you are already doing obviously. The ajax request must include the map name, typically the javascript would look something like this:
> 
> myFunction: function() {
> var map = Fusion.getMapByIndice(0); // a reference to a mapserver map
> var url = 'path/to/my/php/script.php'; // correct URL to your php script
> var params = {
> mapname: map._sMapname,
> session: map.getSessionID(),
> myparam: 'some value' // add all the parameters you want to send as key: value pairs
> };
> var options = {
> onSuccess: OpenLayers.Function.bind(map.reloadMap, map),
> parameters: params
> };
> Fusion.ajaxRequest(url, options);
> }
> 
> you need to be doing something like this on the server side:
> 
> include ("/path/to/fusion/layers/MapServer/php/Common.php");
> 
> if (isset($_SESSION['maps']) && isset($_SESSION['maps'][$mapName])) {
> $oMap = ms_newMapObj($_SESSION['maps'][$mapName]);
> $myparam = $_REQUEST['myparam'];
> // your code that manipulates $oMap
> $oMap->save($_SESSION['maps'][$mapName]);
> }
> ?>
> 
> That's pretty much the simplest way to implement what you need to do I think. Does that make sense?
> 
> Cheers
> 
> Paul
> 
> On 2010-03-11, at 10:18 AM, Tom van der Putte wrote:
> 
> > Hi Paul,
> > 
> > I was doing 3), but that's about it. Could you give me some pointers on how to do do 1) and 2)?
> > 
> > Cheers,
> > Tom
> > 
> > 
> > 
> > On Thu 11/03/10 16:09 , Paul Spencer pspencer at dmsolutions.ca sent:
> > are you:
> > 
> > 1) modifying the session copy of the map file
> > 2) saving the session copy of the map file after modification
> > 3) reloading the map on the client side
> > 
> > Cheers
> > 
> > Paul
> > 
> > On 2010-03-11, at 9:26 AM, Tom van der Putte wrote:
> > 
> > > Hi All,
> > > 
> > > I have a map with several layergroups, and want to make a copy of a user-picked layer in a group by doing an ajax call to a PHP Mapscript. This script executes $oMap->insertLayer($oLayer). This works perfectly in the PHP Mapscript environment ($oMap->getAllLayerNames() shows all layers including the copy). But when the ajax call returns, the layer has not been added to the map. Any ideas why this is? 
> > > 
> > > Cheers,
> > > Tom
> > > _______________________________________________
> > > fusion-users mailing list
> > > fusion-users at lists.osgeo.org
> > > http://lists.osgeo.org/mailman/listinfo/fusion-users
> > 
> > 
> > __________________________________________
> > 
> > Paul Spencer
> > Chief Technology Officer
> > DM Solutions Group Inc
> > http://research.dmsolutions.ca/
> > 
> > 
> 
> 
> __________________________________________
> 
> Paul Spencer
> Chief Technology Officer
> DM Solutions Group Inc
> http://research.dmsolutions.ca/
> 
> 


__________________________________________

   Paul Spencer
   Chief Technology Officer
   DM Solutions Group Inc
   http://research.dmsolutions.ca/



More information about the fusion-users mailing list