[Chameleon] Drawing a Point

Ken-ichi kueda at wso.williams.edu
Thu Aug 12 13:13:35 EDT 2004

Thanks for the tip on the Locate widget.  Unfortunately, as far as I can 
tell, that works by creating a temporary shapefile, adding a point to 
the shapefile, and then setting the shapefile as the data source for the 
new layer.  I want to do something much simpler, which is simply drawing 
a point directly to the map with the pointObj's draw() method.  I've 
done this with MapScript before, basically with this same code.

Does anyone know if there's a better way to get at the ImageObj than 
$map->draw() in Chameleon?  I feel like that's where my problem might be.


Jason Fournier wrote:

>If you take a look at the Locate widget it contains a significant amount of code related 
>to adding a point on the map.  If you're able to swim your way through it you may find 
>some useful tidbits.  
>Perhaps someone else on the list knows offhand?
>If this fails then I'd suggest mailing the MapServer list as there are many PHP/MapScript 
>(and generally more MapScript) developers who may have input.
>As for debugging ... what kind of information were you looking for?  Are you looking for 
>information about Chameleon errors?  This can be reported by the ErrorReport widget.  Or 
>are you interested more in logging the application?
>On Aug 11, Ken-ichi <kueda at wso.williams.edu> wrote:
>>Hi again.  To learn about widget development, I'm trying to make a copy 
>>of the ZoomIn widget draw a point on the map instead of zooming in.  To 
>>that end, I've altered the ParseURL method so that the if( $szInputType 
>>== "POINT" ) clause looks like this:
>>            if ($szInputType == "POINT")
>>            {
>>                $aPixPos = explode(",", $szInputCoords);
>>                //draw a point with MapScript
>>                $map = $this->moMapNavigator->oSession->oMap;
>>                $daLayer = ms_newLayerObj($map);
>>                $daLayer->set("type", MS_LAYER_POINT);
>>                $daLayer->set("transform", MS_FALSE);
>>                $daLayer->set("status", MS_ON);
>>                $class = ms_newClassObj($daLayer);
>>                $class->set("name", "Temp Class");
>>                $style = ms_newStyleObj($class);
>>                $style->color->setRGB(255,0,0);
>>                $style->set("symbolname", "circle");
>>                $style->set("size", 10);
>>                $my_point = ms_newPointObj();
>>                $my_point->setXY($aPixPos[0],$aPixPos[1]);
>>                $image = $map->draw();
>>                $temp = $my_point->draw( $map, $daLayer, $image, 0, 
>>"Temp Point" );
>>                if( $temp == MS_SUCCESS ) $daLayer->set("name", $temp);
>>            }
>>This successfully adds a layer to the legend with the correct styling, 
>>but fails to draw the point on the map.  Note that the last line does 
>>result in setting the name of the new layer to MS_SUCCESS (haven't 
>>figured out how to use any of Chameleon's debugging capabilities, if 
>>such things exist), so the draw() method thinks it's working.
>>Can anyone tell me what I'm doing wrong?  Many thanks.
>>Chameleon mailing list
>>Chameleon at lists.maptools.org
>Chameleon mailing list
>Chameleon at lists.maptools.org

More information about the Chameleon mailing list