RV: [Chameleon] Drawing points with latitude and longitude - Please help me

Julien-Samuel Lacroix jlacroix at mapgears.com
Fri Dec 8 10:47:30 EST 2006


Hi,

Everything seems right.
You can remove that line though:
$this->mszCoords = $poLayer;

When you click on the button, it should add a point in the LandSat-modis 
layer. Few hints that may help you:
- The LandSat-modis layer should be a POINT layer with no DATA element.
- The LandSat-modis layer should have a CLASS and STYLE to be able to be 
drawn correctly.
- Since you hardcoded it, the point will always be at the following 
coordinates:
8.911825673734443, -79.41222265835958
- Is Lat/Lon is the projection of the mapfile and others layer? This may 
be your problem. If the layer is not in the right projection, it won't 
show correctly.
- You can send the LandSat-modis layer definition if you want so we can 
check.

Hope that helps.
Julien

PS: Oh! and is the status of the layer is set to ON or DEFAULT?

Ines wrote:
> Julien, thank you again for your help, but I have a problem with my widget.
> I can`t still show the point in the map. I think I have to make something
> for the output to the web page.
> 
> I was learning the pdf you send me and another things about Map Script in
> Map Server web page. But I have still problem in my widget. When I click the
> button of the widget in my web page, It don't do nothing.
> 
> 1) Define Variables:
> 
> class UUW extends NavTool
> {
>     // define member vars
>     // i.e.  var $mszMyVariable;
> 	var $x;
> 	var $y;
> 	var $mszCoords;
> 
> 	var $poLayer;
> 	var $pt;
>    	var $ln;
> 	var $shp;
>    	var $pt;
>       var $ln;
>       var $shp;
> 
> 
> 2) The Attributes added in the Constructor are what you may pass to your
> widget XML tag:
> 
> 
>     function UUW()
>     {
>         // set the language file
>         $this->mszLanguageResource = dirname(__FILE__).'/UUW.dbf';
> 
>         // invoke constructor of parent
>         parent::NavTool();
> 
> 
>         /////////  ADD ATTRIBUTES HERE  /////////
> 
> 
> 		$this->maAttributes['COORDS'] =
>             new StringAttribute( 'COORDS', true, array( 'aa' ) ); ---->
> ATTRIBUTES
> 
>         // set the description for this widget
>         $this->szWidgetDescription = <<<EOT
> This is the UUW.
> EOT;
>         // set the maturity level
>         $this->mnMaturityLevel = MATURITY_ALPHA;
> 
>     // end constructor
>     }
> 
> 3) In InitDefault, you initialise all your variables with what was passed
> in the XML tag. Everything is available via the Params array:
> 
> function InitDefaults()
>     {
>         // init defaults for parent
>         parent::InitDefaults();
> 
>         /////////  ADD CODE HERE IF NECESSARY /////////
> 
> 
> 		$this->mszCoords = isset( $this->maParams['COORDS'] )?
> 
>             $this->maParams['COORDS'] : ''; ------->INITIALIZE VARIABLE
> 
> 
> 		// init the widget defaults
> 		//$this->SetNavCommand('UUW');
> 		//$this->mszReport = '';
> 
> 
>     // end InitDefaults function.
>     }
> 
> 4) The ParseURL is the most important. It is there that all the
> processing is done. Here you can read the URL variables, modify the map,
> modify the session, etc.
> 
> function  ParseURL()
>     {
>         // execute parent function
>         parent::ParseURL();
> 
>         /////////  ADD CODE HERE IF NECESSARY /////////
> 		// work some magic
> if ( $this->isVarSet( "NAV_CMD" ) &&
>                             $this->getVar( "NAV_CMD" ) == 'UUW' )
> {
> 
> 
> 	$this->x = 8.911825673734443;
> 	$this->y = -79.41222265835958;
> 
> 	if ( $this->mszCoords == 'aa')
> 	{
> 		$poLayer = $this->moMapObject->oMap->getLayerByName('LandSat-modis');
> 		$pt = ms_newPointObj();
>    		$ln = ms_newLineObj();
> 		$shp = ms_newShapeObj(MS_SHAPE_POINT);
>    		$pt->setXY($this->x,$this->y);
>     	      $ln->add($pt);
>     	      $shp->add($ln);
>     	      $poLayer->addFeature($shp);
> 
> 		$this->mszCoords = $poLayer; --------> i'M NOT SURE IF I HAVE TO PASS
> "$poLayer"
> 	}
> 
> 
> }
> 
> 5) Draw publish:
> 
> function DrawPublish()
>     {
>         // init vars
>         $szReturn = "Search by scientific name <input type='text'
> name='textfield'>";
> 
>         // execute parent
>         $szReturn .= parent::DrawPublish();
> 
>         /////////  ADD CODE HERE IF NECESSARY /////////
> 
>         // return
>         return $szReturn;
> 
>     // end DrawPublish() function
>     }
> 
> 6) Template.html:
> 
> <cwc2
>    type="UUW"
>    coords="aa" ----------> CONTENT OF COORDS
>    imagetip="Info"
>    image="icons/icon_query.png"
>    styleresource="NavButtons"
>    imagewidth="25"
>    toolset="nav">
>      <image state="normal"/>
>      <image state="hover"/>
>      <image state="selected"/>
>  </cwc2>
> 
> 
> I think I'm near to show the point but I don't know how to output the point
> in the map.
> 
> Thank you again,
> Ines
> 

-- 
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/


More information about the Chameleon mailing list