[Chameleon] Custom Widget, problem showing Point Layer

Ines mleonsoft at yahoo.com.ar
Tue Jan 2 10:34:51 EST 2007


Hello, I'm trying to show a point layer with  my custom widget but I have
problems to do it. My widget don´t do nothing.
I created a point layer in the file.map with the status "On" or "Default"
and it is working very well (It apeears in the legend and show me the point
on the map). But I need to make this point dynamic with the custom widget,
because the latitude and longitude will be changing (dynamic).

When I click on the button of my widget, the web page (my application) don't
do nothing. I don´t know how to solve this problem. Perhaps I´m doing
something wrong in the widget but I don´t know what. I'm going crazy with
the custom widget and I really need to solve this problem. I really need
your help.

Well, I need to make the point layer appears in the map when I click the
buttom of the widget. And I need to have the point layer status "Off" when I
run the application for first time, and then, set to "On" just when I click
the button of the widget.

I´m show you:
1) The point Layer in the file.map
2) The code in the widget
3) The cwc2 tag in the template.html

1) The point Layer in the file.map

LAYER
  	NAME "pointlatlon"
	PROJECTION
      "init=epsg:4326"
    END
	TYPE POINT
	STATUS OFF
	FEATURE
		POINTS
			-85.933333 13
		END
		TEXT "My Place"
	END
	CLASS
		COLOR 255 0 0
		OUTLINECOLOR 255 255 255
		SYMBOL "circle"
		SIZE 10

		LABEL
			POSITION AUTO
			COLOR 98 223 45
			OUTLINECOLOR 255 255 255
		END
	 END
   END
----------------------------------------------------------------------------
------------

2) The code in the widget


a) ------------------"UUW" Widget
Class--------------------------------------------------

// inherit from the NavTool
include_once(dirname(__FILE__)."/../NavTool.php");
include( 'utils.inc.php' );

/**

____________________________________________________________________________
_
 |
 | "UUW" Widget Class

|___________________________________________________________________________
__

 **/
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;


//	var	$mszReport;

    /////////  ADD MEMBER VARS HERE  /////////

    /**

_________________________________________________________________________
     |
     | Constructor: "UUW" Widget Class

|_________________________________________________________________________

     **/
    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' ) );

        // set the description for this widget
        $this->szWidgetDescription = <<<EOT
This is the UUW.
EOT;
        // set the maturity level
        $this->mnMaturityLevel = MATURITY_ALPHA;

    // end constructor
    }

b) ------------------function
InitDefaults()--------------------------------------------

function InitDefaults()
    {
        // init defaults for parent
        parent::InitDefaults();

        /////////  ADD CODE HERE IF NECESSARY /////////


		$this->mszCoords = isset( $this->maParams['COORDS'] )?

            $this->maParams['COORDS'] : '';



    // end InitDefaults function.
    }


c) ------------------function
ParseURL()---------------------------------------------------

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 = -85;
	$this->y = 13;

	if ( $this->mszCoords == 'aa')
	{
		$poLayer = $this->moMapObject->oMap->getLayerByName('pointlatlon');
		$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);

	}

}

        // return success
        return true;
    }


d) ------------------function
DrawPublish()-----------------------------------------------


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
    }
----------------------------------------------------------------------------
------------------


3) The cwc2 tag in the template.html

<cwc2
   type="UUW"
   coords="aa"
   imagetip="Info"
   image="icons/icon_query.png"
   styleresource="NavButtons"
   imagewidth="25"
   toolset="nav">
     <image state="normal"/>
     <image state="hover"/>
     <image state="selected"/>
 </cwc2>


Rally thank you very much,
Ines



More information about the Chameleon mailing list