php_mapscript - showing polygon and point/annotation layers
Mike Reilly
mikereilly2 at GMAIL.COM
Tue Aug 23 23:53:34 PDT 2005
I have mostly completed a cgi mapserver application and am now trying
to convert parts of it over to php_mapscript. I found it fairly
simple to draw a map from a mapfile using php, but now am starting to
learn a few more features and ran across the following stumbling
block:
If I use map->draw() I get an image created with all of the features
in the mapfile (all 68 layers, whee!). This is expected behaviour.
Because I want ot be able to select individual layers depending on
users preferences, I have been experimenting with map->prepareimage()
and then a series of layer->draw($image) - one of these for each
layer. I then do a map->drawLabelCache() to ensure labels are drawn
on the map and finally save the map to temp and echo out the html to
display it. The problem is that while the labels are displaying jsut
fine, any polygon or point/annotation data does not get displayed.
What am I missing here (by the way, I get the impression I haven't
done a great job of formatting the map file - please feel free to
point out any errors and make suggestions).
Here's the php code:
$mymap=ms_newmapobj('php.map');
$image=$mymap->prepareImage();
$currentlayer=$mymap->getLayerByName("landpl");
$a=$currentlayer->draw($image);
$currentlayer=$mymap->getLayerByName("boundary");
$a=$currentlayer->draw($image);
$currentlayer=$mymap->getLayerByName("lakespl");
$a=$currentlayer->draw($image);
$currentlayer=$mymap->getLayerByName("coastln");
$a=$currentlayer->draw($image);
$currentlayer=$mymap->getlayerbyname("tusnotavailable");
$a=$currentlayer->draw($image);
;
$a=$mymap->drawLabelCache($image);
$imageurl=$image->saveWebImage();
echo "<img src=".$imageurl.">";
The landpl, boundary, lakespl and coastln all work fine, but
tusnotavailable and a number of other layers similar to it don't.
Here's the tusnotavailable layer (I'll put the other 3 working layers
at the end).
LAYER
NAME tusnotavailable
DATA "tus points"
STATUS ON
MAXSCALE 5000000000
TYPE ANNOTATION
LABELITEM "USE1"
CLASSITEM "USE1"
LABELMAXSCALE 500000000
TOLERANCE 3
CLASS
EXPRESSION "not available"
SYMBOL 7
SIZE 6
TEMPLATE "templates/pointdata_query.html"
COLOR 255 0 0
LABEL
COLOR 0 0 0
TYPE TRUETYPE
FONT arial
SIZE 12
POSITION CC
PARTIALS FALSE
BUFFER 2
END
END
END
Here are the layers that are being displayed correctly:
LAYER
NAME "coastln"
DATA "coastln"
STATUS DEFAULT
TYPE LINE
CLASS
COLOR 0 0 200
OUTLINECOLOR 0 0 200
END
END
LAYER #land polygons
NAME "landpl"
DATA "landpl"
STATUS DEFAULT
TYPE POLYGON
CLASS
COLOR 211 255 190
OUTLINECOLOR 211 255 190
END
END
LAYER #Creeks
NAME "streamln"
DATA "streamln"
STATUS ON
TYPE LINE
CLASS
COLOR 0 70 230
OUTLINECOLOR 0 70 230
END
END
LAYER #lakes polygons
NAME "lakespl"
DATA "lakespl"
STATUS DEFAULT
TYPE POLYGON
CLASS
COLOR 207 245 255
OUTLINECOLOR 100 100 255
END
END
More information about the MapServer-users
mailing list