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

Ines mleonsoft at yahoo.com.ar
Mon Dec 18 18:46:09 EST 2006




Julien, I maked some changes. yes, my problem was that the layer was not a
POINT Layer. Now I will show you my changes. Now, the POINT layer appears in
the legend in the web page (it is set to "ON"), but it don´t appears drawn
in the map, and when I click the button it don´t appears drawn in the map.

My changes:

1)

You can remove that line though:
$this->mszCoords = $poLayer; -----------> I removed this line

2) The LandSat-modis layer should be a POINT layer with no DATA element: OK,
it is my new layer in the map file:
Now, the name is: "point-lat-lon" and I changed in the widget:
$poLayer = $this->moMapObject->oMap->getLayerByName('point-lat-lon');

LAYER
  	NAME "point-lat-lon"
	PROJECTION
      "init=epsg:4326"
    END
	TYPE POINT
	STATUS ON
	FEATURE
		POINTS
			-121 54
		END
		TEXT "My Place"
	END
	CLASS
		COLOR 250 0 0
		OUTLINECOLOR 255 255 255
		SYMBOL "circle"
		SIZE 10
		LABEL
			POSITION AUTO
			COLOR 250 0 0
			OUTLINECOLOR 255 255 255
		END
	 END
   END


3) I added in the map file "SYMBOL" later of "CONFIG "CGI_CONTEXT_URL" "1":

MAP
  EXTENT -104 4 -57 27
  FONTSET "../etc/fonts.txt"
  IMAGECOLOR 255 255 255
  IMAGETYPE jpeg
  SYMBOLSET "../etc/symbols.sym"
  SHAPEPATH "../data"
  SIZE 750 375
  STATUS ON
  UNITS DD
  NAME "GeoIntegrator"
  CONFIG "CGI_CONTEXT_URL" "1"

 SYMBOL
 	NAME "circle"
	TYPE ELLIPSE
	FILLED TRUE
	POINTS
		1 1
	END
 END

OUTPUTFORMAT
   NAME jpeg
   DRIVER GD/JPEG
   MIMETYPE image/jpeg
   EXTENSION jpg
   IMAGEMODE RGB
END

  PROJECTION
    "init=epsg:4326"
  END
  LEGEND..............


My idea is set the "point-lat-lon" layer to Off in the map file and when I
click the button of the layer the status change to "ON" and draw the point
in the map. But I need first see that red point in the map with the status
"ON" to see it. All the layers in the map file are of "Central America", I
checked the latitude and longitude that I'm using in the widget and I see it
are Ok. It are from "Panama" and the lat/lon I'm proving seems ok.


Thank you again
Ines




-----Mensaje original-----
De: Julien-Samuel Lacroix [mailto:jlacroix at mapgears.com]
Enviado el: viernes, 08 de diciembre de 2006 12:48
Para: Ines
CC: chameleon at lists.maptools.org
Asunto: Re: RV: [Chameleon] Drawing points with latitude and longitude -
Please help me


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