[fusion-users] ¿How to programatically change the raster file a layer is pointing to?

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Mon Feb 23 08:28:00 EST 2009


Instead of fidling with dynamic layer setup, could you just create a 
number of layers,
and then toggle visibility to show only the correct GeoTiff?

Regards, Kenneth Skovhede, GEOGRAF A/S



jsanchez skrev:
>
> As I suspected, my kung-fu wasn't strong enough to solve the problem I
> described in my previous post.
> Thank to Paul tips I've made some progress but I failed to get what I was
> looking for.
> I've changed a little my initial approach and that's why I'm posting this in
> a new thread. 
>
> 1) I'm using a little mapfile with only four layers, one of them (the base
> layer) is a raster which points to a 'image1.tif'.
>
> 2) I'd like to have the possibility to select the geotiff shown as base
> layer.
>
> 3) I think the way to do this in mapscript is to 'redirect' the parameter
> 'data' of the layer to a new raster file:
>
>             $oMap = ms_newMapObj($szMapFile);
>             $baselayer=$oMap->getLayer(0);
>             $baselayer->set("data" "image2.tif");
>
> But I have no idea about how to transfer the name of new image from my form
> at index.html to LoadMap.php.
>
> 4) From Paul code I understood that the right way to do this was introducing
> in index.html a couple of functions like these:
>
> function ChangeRaster(newimage) {
>     var params='mapfile=/var/www/data/mapfile.map&newdata='+newimage;
>     var opts = {parameters: params, onComplete: reload.bind(null)};
>     var s =  "layers/MapServer/php/ChangeRaster.php";
>     Fusion.ajaxRequest(s, opts);
> }
>
> function reload(){
>     var mapWidget=Fusion.getMapById('Map');
>     maps=mapWidget.getAllMaps();
>     map=maps[0];
>     map.reloadMap();
> }
>
> ChangeRaster.php is just a copy of LoadMap.php in which I inserted the
> mapscript code mentioned above to change the data of the layer:
>
>             $newimage=$_REQUEST['newdata'];
>             $oMap = ms_newMapObj($szMapFile);
>             $baselayer=$oMap->getLayer(0);
>             $baselayer->set("data", $newimage);
>
> As far as I understand, by selecting a new raster from a listbox,
> 'ChangeRaster()' is called, then 'ChangeRaster.php' is executed and when
> completed, 'reload()' is called to make a map reload showing the updated
> image. 
>
> Unfortunately, it didn't work and I have no more ideas to test.....
>  Any clues would be appreciated.
>
>
> J. Sanchez
>   


More information about the fusion-users mailing list