0

I'm manipulating mapfiles through mapscript. Setting layer attribute values like the opacity works like this:

$layer = $map->getLayer('layername');
//set an attribute value
$layer->set('opacity', 80);

But now I want to set the data attribute as well, I assumed it functions like this:

$layer = $map->getLayer('layername');
//set an attribute value
$layer->set('data', '/path/to/my/shape/file.shp');

But nothing happens, i.e. an image is constructed but it's empty because no data was inserted.

How can I set the data string?

I'm using Mapserver 5.0.3 + Mapscript 4.10


I used the map.getLayer() method instead of the getLayerByName method. While testing on the opacity attribute, I had a mapfile with only one layer, so the getLayer('loadlines') did return a (but in this case the last and correct) layer.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Sep 19, 2013 at 16:02

1 Answer 1

1
$layer = $map->getLayerByName('layername');
//set an attribute value
$layer->set('data', '/path/to/my/shape/file.shp');

or

$layer = $map->getLayer('layer_index'); //integer!
//set an attribute value
$layer->set('data', '/path/to/my/shape/file.shp');
answered Sep 24, 2013 at 8:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.