[Mapserver-users] Layer status problem and reference map problem..

Eric Bridger eric at gomoos.org
Fri Jul 18 09:13:35 EDT 2003


Ali,

I think you have a syntax error:
> $current_layer = $current_map->getLayerByName('$layer');
should be:
$current_layer = $current_map->getLayerByName("$layer");

Perl will not interpolate the variable in single quotes.

For the reference map, you would have to make sure that $ref_image_id
was different for each request.  The browser is caching the image since
it has the same URL.
I always use mapserv in reference mode as the image source, e.g.

/cgi-bin/mapserv?map=/full/path/to/some.map&mapext=$map_ext&mode=reference

Since it's a CGI the browser will request it each time.

Eric


On Fri, 2003-07-18 at 15:46, AMC Story wrote:
> Hi there, 
> 
> I've got a couple of questions which I think must be fairly straight-forward 
> but I can't seem to figure them out myself.....
> 
> Firstly, I've set up some checkboxes in the HTML interface which should allow 
> users to turn certain layers on and off.  I have a couple of layers that are 
> always on (i.e. set to DEFAULT in the map file), and a couple of others which 
> are set to OFF in the map file, but which the user can select to be turned on.  
> The selected layers are passed with the URL and populate an array called 
> @layers.  I've then used the following code to update the status of these 
> layers:
> 
> ##Turn on appropriate layers
> foreach $layer (@layers){
> $current_layer = $current_map->getLayerByName('$layer');
> $current_layer->{status} = $mapscript::MS_ON;
> }
> 
> I've printed the status to the screen and for each layer that was selected, the 
> status was updated to "1" as I expected.
> 
> The map is then drawn as follows:
> 
> #draw and save main map to PNG
> $image = $current_map->draw();
> $image->saveImage($image_path.$image_id,$mapscript::MS_PNG,
> $current_map->{transparent}, $current_map->{interlace}, 0);
> 
> However, this map only displays the layers that were set as "DEFAULT" in the 
> map file, and the newly-updated "on" status for the other layers seems to be 
> ignored.  Do I have to do something else to get these layers to be displayed?
> 
> Also, once the main map has been created, I then create a reference map like so:
> 
> #Create reference map image
> $ref_img = $current_map->drawReferenceMap();
> $ref_img->saveImage($image_path.$ref_image_id,$mapscript::MS_PNG,
> $current_map->{transparent}, $current_map->{interlace}, 0);
> 
> The problem here is that the reference map often doesn't update itself, which 
> would obviously be quite disconcerting for the user.  The reference map can be 
> made to update if you click on the browser's refresh/reload button, but surely 
> this shouldn't be necessary?
> 
> Any ideas would be great.
> 
> Thanks,
> Ali
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 





More information about the mapserver-users mailing list