[fusion-users] ¿How to programatically change the raster file a layer is pointing to?
jsanchez
ebarrera at inm.es
Sat Feb 21 09:13:30 EST 2009
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
--
View this message in context: http://n2.nabble.com/%C2%BFHow-to-programatically-change-the-raster-file-a-layer-is-pointing-to--tp2363798p2363798.html
Sent from the Fusion Users mailing list archive at Nabble.com.
More information about the fusion-users
mailing list