[Chameleon] Visualize selected/queried layer

Bart van den Eijnden BEN at Syncera-ITSolutions.NL
Mon Sep 19 06:48:28 EDT 2005


Hilbert,

then you should study in general how Chameleon widgets operate. I can't go and explain all that in an e-mail. There is a tutorial out there from DMSG.

Basically, this kind of code should go into the ParseURL function of the respective widgets (to which you want to add this kind of functionality). Btw I am assuming you are not using Chameleon's JSAPI mode.

Best regards,
Bart

Bart van den Eijnden
Syncera IT Solutions
Postbus 270
2600 AG  DELFT

tel.nr.: 015-7512436
email: BEN at Syncera-ITSolutions.nl

>>> "Davelaar, Hilbert" <Hilbert.Davelaar at wur.nl> 19-9-2005 12:13:20 >>>
Hi Bart,
 
Can you point me into the right direction please? Otherwise I will keep on struggling with the code you provided. Where do I have to put the code? What do I have to change, etc.?
 
Kinds regards,
Hilbert

	-----Oorspronkelijk bericht----- 
	Van: chameleon-bounces at lists.maptools.org namens Davelaar, Hilbert 
	Verzonden: ma 19-9-2005 11:12 
	Aan: Bart van den Eijnden; chameleon at lists.maptools.org 
	CC: 
	Onderwerp: RE: [Chameleon] Visualize selected/queried layer
	
	

	Thank you Bart, I will give this piece of code a try. Hope I will be able to promote it to be the solution...
	
	Kind regards,
	Hilbert
	
	        -----Oorspronkelijk bericht-----
	        Van: Bart van den Eijnden [mailto:BEN at Syncera-ITSolutions.NL] 
	        Verzonden: ma 19-9-2005 11:06
	        Aan: chameleon at lists.maptools.org; Davelaar, Hilbert
	        CC:
	        Onderwerp: RE: [Chameleon] Visualize selected/queried layer
	       
	       
	
	        What's even easier than using SLD (SLD will work mainly for WMS layers) would be just copying your layer with Mapscript, changing the symbology to a selection color, and setting the filteritem and filter. Here's some example code for that:
	       
	            $oMap = $oMapSession->oMap;
	       
	            // if selection layer exists, delete it first
	            for ( $i=0; $i<$oMap->numlayers;  $i++ )
	            {
	              $oTempLayer = $oMap->getlayer($i);
	              if ( $oTempLayer->name == 'StraGISWebSelection' )
	              {
	                $oTempLayer->set( 'status', MS_DELETE );
	                break;
	              }
	            }
	       
	            $szLayerName = "";
	            if (isset($HTTP_FORM_VARS["LAYER_NAME"]))
	              $szLayerName = $HTTP_FORM_VARS["LAYER_NAME"];
	       
	            $szFilter = "";
	            if (isset($HTTP_FORM_VARS["LAYER_FILTER"]))
	              $szFilter = $HTTP_FORM_VARS["LAYER_FILTER"];
	       
	            $szSelectionColor = "";
	            if (isset($HTTP_FORM_VARS["SELECTION_COLOR"]))
	              $szSelectionColor = $HTTP_FORM_VARS["SELECTION_COLOR"];
	       
	            $arSelectionColor = explode(",", $szSelectionColor);
	       
	            $szSelectionWidth = "";
	            if (isset($HTTP_FORM_VARS["SELECTION_WIDTH"]))
	              $szSelectionWidth = $HTTP_FORM_VARS["SELECTION_WIDTH"];
	       
	            for ($i=0; $i<$oMap->numlayers; $i++)
	            {
	              $oLayer = $oMapSession->oMap->GetLayer($i);
	              if ($oLayer->name == $szLayerName)
	              {
	                // copy layer
	                $oSelectionLayer = ms_newLayerObj( $oMap, $oLayer );
	                // move selection layer to top!
	                while ($oMap->moveLayerDown($oSelectionLayer->index) != 0)
	                {
	                  ;
	                }
	                $oSelectionLayer->set( 'name', 'StraGISWebSelection' );
	                $oSelectionLayer->set( 'template', '' );
	              
	                if ($oSelectionLayer->connectiontype == MS_POSTGIS)
	                {
	                  // BEN, 13-09-2005, for PostGIS, filter item does not work
	                  $oSelectionLayer->setFilter($oSelectionLayer->filteritem.'='.$szFilter);
	                }
	                else
	                {
	                  $oSelectionLayer->setFilter($szFilter);
	                }
	                // set color to selection color
	                for( $j=0; $j < $oSelectionLayer->numclasses; $j++)
	                {
	                  $oClass = $oSelectionLayer->getClass($j);
	                  for ($k=0;$k<$oClass->numstyles;$k++)
	                          {
	                    if ($oSelectionLayer->type == MS_LAYER_POLYGON)
	                    {
	                      $oClass->deletestyle($k);
	                    }
	                    else
	                    {
	                      $oStyle = $oClass->getStyle($k);
	                      $oStyle->color->setRGB( $arSelectionColor[0], $arSelectionColor[1], $arSelectionColor[2] );
	                      $oStyle->outlinecolor->setRGB( 0,0,0 );
	                    }
	                  }
	                  if ($oSelectionLayer->type == MS_LAYER_POLYGON)
	                  {
	                    // add a new style
	                    $oStyle = ms_newStyleObj( $oClass );
	                    $oStyle->set("symbolname", "circle");
	                    $oStyle->set("size", $szSelectionWidth);
	                    $oStyle->outlinecolor->setRGB( $arSelectionColor[0], $arSelectionColor[1], $arSelectionColor[2] );
	                  }
	                }
	                $oSelectionLayer->set( 'status', MS_ON );
	              }
	            }
	       
	        Best regards,
	        Bart
	       
	        Bart van den Eijnden
	        Syncera IT Solutions
	        Postbus 270
	        2600 AG  DELFT
	       
	        tel.nr.: 015-7512436
	        email: BEN at Syncera-ITSolutions.nl 
	       
	        >>> "Davelaar, Hilbert" <Hilbert.Davelaar at wur.nl> 19-9-2005 10:54:48 >>>
	        Hi Bart,
	       
	        I don't have any experience with SLD, and though you mentioned the ExpressionBuilder widget as a reference, I can't find any example code. You know where exactly I can find some introductory code into the use of SLD for those purposes?
	       
	        Kind regards,
	        Hilbert
	       
	                -----Oorspronkelijk bericht-----
	                Van: chameleon-bounces at lists.maptools.org namens Bart van den Eijnden
	                Verzonden: ma 19-9-2005 9:38
	                Aan: chameleon at lists.maptools.org; Davelaar, Hilbert
	                CC:
	                Onderwerp: Re: [Chameleon] Visualize selected/queried layer
	              
	              
	       
	                Hilbert,
	              
	                you can do this with SLD, it will require some programming though and a map refresh each time, you can look at the ExpressionBuilder widget for example code.
	              
	                Best regardas,
	                Bart
	              
	                Bart van den Eijnden
	                Syncera IT Solutions
	                Postbus 270
	                2600 AG  DELFT
	              
	                tel.nr.: 015-7512436
	                email: BEN at Syncera-ITSolutions.nl 
	              
	                >>> "Davelaar, Hilbert" <Hilbert.Davelaar at wur.nl> 19-9-2005 9:29:18 >>>
	                Hi list,
	              
	                I want to have certain functionality in my Chameleon application, but I'm wondering if it's possible. Maybe someone can tell me to stop trying to implement it or give me a way to do it.
	              
	                I have a polygon layer in my mapfile. Using the query widget the user is able to query this layer. But now I want to visualize the polygonfeature the user has queried, so after he has clicked he still can see to which polygon the query results apply. For example by another outline of this polygon or another color. It would be great if this is possible.
	              
	                Same thing I want to implement for te QuickZoom widget. From this widget the user is able to zoom to a polygon. It is possible then to show the user which is the polygon he zoomed at, instead of the fact that he has to assume its the polygon in the center of the map?
	              
	                Kind regards,
	                Hilbert Davelaar
	              
	                _______________________________________________
	                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 
	              
	       
	       
	
	
	_______________________________________________
	Chameleon mailing list
	Chameleon at lists.maptools.org 
	http://lists.maptools.org/mailman/listinfo/chameleon 
	




More information about the Chameleon mailing list