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.

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');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.