[mapserver-users] Draw PHP labels

Daryl Herzmann akrherz at iastate.edu
Fri Aug 23 06:39:42 PDT 2013


Hello,

Instead of:

$oAirportsClass->label->set("size", 10);


do:


$oAirportsClass->getLabel(0)->set("size", 10);


http://mapserver.org/mapscript/php/phpmapscript.html#classobj


daryl



On Wed, Aug 21, 2013 at 12:48 PM, Michael McInnis <mmcinnis59 at msn.com>wrote:

> Dear mapservers!
>
> My map fails to draw when I attempt to add labels from my labelitem "icao".
>
> Any attempt at using the label objects causes failure. I think I need to
> create a label object
> somehow before I use set() but can't find any examples on line.
>
> // The following occurs near the bottom of my php code snippet and is
> commented to allow a successful draw.
>
> $oAirportsClass->label->set("size", 10);
>
>
>
> Can someone point me to a working example of drawing labels for a layer?
>
> Thanks
>
>
>
>
> // Layer 3 airports--------------------------------------------------------
>
> // Point Symbol
> $nSymbolId = ms_newSymbolObj($oMap, "circle");
> $oSymbol = $oMap->getsymbolobjectbyid($nSymbolId);
> $oSymbol->set("type", MS_SYMBOL_ELLIPSE);
> $oSymbol->set("filled", MS_TRUE);
> $aPoints[0] = 1;
> $aPoints[1] = 1;
> $oSymbol->setpoints($aPoints);
>
> // Layer
> $oLayerAirports = ms_newLayerObj($oMap);
> $oLayerAirports->setConnectionType(MS_POSTGIS);
> $oLayerAirports->set("name", "airports");
> $oLayerAirports->set("type", MS_LAYER_POINT);
> $oLayerAirports->set("status", MS_DEFAULT);
> $oLayerAirports->set("labelitem", "icao");
> //$oLayerAirports->set("classitem", "MyAirports");
> $oLayerAirports->set("connection", "host=xxx port=xxxx dbname=xxxx user=xxxx password=xxxx");
> $oLayerAirports->set("data", "geom From (select a.icao, geom From airports a left join airportdata e on a.icao = e.icao where e.icao Is Not Null) as subquery using unique icao using srid=4326");
>
> // Class with Labels
> $oAirportsClass = ms_newClassObj($oLayerAirports);
> $oAirportsClass->set("name","MyAirports");
>
> // Style
> $airportsStyle = ms_newStyleObj($oAirportsClass);
> $airportsStyle->color->setRGB(255, 22, 22);
> $airportsStyle->set("symbolname", "circle");
> $airportsStyle->set("size", "3");
>
> //$oAirportsClass->label->set("size", 10);
> //$oAirportsClass->label->color->setRGB(0,0,0);
>
>
>
> Michael McInnis 6033 44th Ave. N.E. Seattle, WA 98115 206 517-4701
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20130823/10c0a6c0/attachment.html>


More information about the mapserver-users mailing list