[Chameleon] Drawing a Point

Ken Sanderson ken at rockies.ca
Thu Aug 12 13:32:51 EDT 2004


I just let Chameleon do the drawing, as my widget triggers the submit of
the form. Here is my ParseURL blurb that I am using:

        if ($szCmd == "GetPoint"){
            /** get a list of the layer names */	
            $aszLayerNames =
$this->moMapNavigator->oSession->oMap->getAllLayerNames();
            
            /** check to see if the 'your points' layer already exists.
If so just use that layer,
                if not then create it */
            if(in_array("Your Points", $aszLayerNames)){
              $poLayer =
$this->moMapNavigator->oSession->oMap->getLayerByName("Your Points");
              $poClass = $poLayer->getClass(0);
              $poStyle = $poClass->getStyle(0);
            } else {
              /** creating the new layer which will live as long as the
current session */
              $poLayer = ms_newLayerObj($this->moMapObject->oMap);
              $poLayer->set("name", "Your Points");
              $poLayer->set("status", MS_ON);
              $poLayer->set("type", MS_LAYER_POINT);
              $poLayer->set("labelcache", MS_OFF);
              $poClass = ms_newClassObj($poLayer);
              $poClass->set("name", "dynamic point class");
              $poStyle = ms_newStyleObj($poClass);
              $poStyle->set("symbolname","star");
              $poStyle->set("size", 15);
              $poStyle->color->setRGB(255, 0, 0);
              $poStyle->outlinecolor->setRGB(0,0,0);
            }
            
            $pt = ms_newPointObj();
            $ln = ms_newLineObj();
            $shp = ms_newShapeObj(MS_SHAPE_POINT);  
            
            $theX = "";
            $theX = $this->getVar("CursorPos_X");
            $theY = "";
            $theY = $this->getVar("CursorPos_Y");
                        
            $pt->setXY($theX,$theY); 
            $ln->add($pt); 
            $shp->add($ln);  
            $poLayer->addFeature($shp);
        }

Ken

-----Original Message-----
From: chameleon-bounces at lists.maptools.org
[mailto:chameleon-bounces at lists.maptools.org] On Behalf Of Ken-ichi
Sent: August 12, 2004 11:14 AM
To: Jason Fournier
Cc: chameleon at lists.maptools.org
Subject: Re: [Chameleon] Drawing a Point


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.

-Ken-ichi

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?
>
>Thanks,
>Jason
>
>
>
>
>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.
>>
>>-Ken-ichi
>>_______________________________________________
>>Chameleon mailing list
>>Chameleon at lists.maptools.org
>><a
>>    
>>
>href='http://lists.maptools.org/mailman/listinfo/chameleon'>http://list
>s.maptools.org/mail
>man/listinfo/chameleon</a>
>  
>
>_______________________________________________
>Chameleon mailing list
>Chameleon at lists.maptools.org 
>http://lists.maptools.org/mailman/listinfo/chameleon
>  
>

_______________________________________________
Chameleon mailing list
Chameleon at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/chameleon




More information about the Chameleon mailing list