[fusion-users] Dynamic selection

Tom van der Putte tom at vdputte.nl
Thu Oct 15 11:05:01 EDT 2009


UPDATE:

I have done some more investigating, and I came up with the following. The
main part of the PHP script is as follows:

------------------------------------
$result = NULL;
$result->hasSelection = false;
$result->layers = array();

if (@$oLayer->queryByAttributes($field,$expression, MS_MULTIPLE) ==
MS_SUCCESS)
{
	$image=$oMap->drawQuery();
	$oMap->savequery(getSessionSavePath()."query.qry");
    $result->hasSelection = true;
    $layerName = $oLayer->name;
    array_push($result->layers, $layerName);
    $result->$layerName->featureCount = $oLayer->getNumResults();
    $result->queryFile = getSessionSavePath()."query.qry";
}
$image_url=$image->saveWebImage();

header('Content-type: text/x-json');
header('X-JSON: true');

echo var2json($result);
------------------------------------

The resulting responseText of the json object is:

{"hasSelection":true,"layers":["wells"],"wells":{"featureCount":5},"queryFile":"d:/ms4w/tmp/sess_4ad7352b40606/query.qry"}

The relevant part of the Widget is:
------------------------------------
eval("o="+r.responseText);
this.oMap._sQueryfile = o.queryFile;	
this.oMap.triggerEvent(Fusion.Event.MAP_SELECTION_ON, this.oMap);
this.oMap.redraw();
------------------------------------

At first this does nothing. However, if I manually select some features and
then I run the widget, it selects and highlights the features correctly.
After some trying, I found that this behaviour persists is all lines from
above are removed, and only the redraw function is called. It seems to be
that oMap.hasSelection() returns false, unless something is selected
manually. Setting this.oMap.aMaps[0].bSelectionOn to true does not help,
although oMap.hasSelection() will return true after this statement.

This does not seem to be correct behaviour. Can anybody help me to create a
script that will automatically uses the selection from the mapscript, and
then highlights these features?

Thx, Tom

PS. there might be some code in the mapscript or js that is unnecessary, but
that's probably because of the trial and error way of doing things. Feel
free to comment!



Tom van der Putte wrote:
> 
>   BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px;
> }Hello List,
>  I am currently in the process on grasping the PHP_Mapscript/Fusion
> combination on a Mapserver/WinXP installation. Using the CookBook and
> the source files, I have already managed to do some stuff, but I'm
> kinda stuck at the moment.
>  For simplicity let's say I'm using a map with one layer, containing
> point features, stored in a postgis table. What I want to do is select
> these features based on a certain attribute/value combination (entered
> by the user), display the feature info and additional info, and
> highlight the features in the current map.
>  One issue is that the query to select features is done in two steps:
> the first is a posGIS query (query 1). It uses the attribute/value
> combination entered by the user to create a join; depending on the
> attribute, a different join is created. (This is why I do not join in
> the layers data directive.) The result (result1) contains the feature
> ids, and additional info from the joined tables. This info is then
> sent back to the widget and displayed in a resultPanel. So far so
> good, and everything works.
>  However, I also want to highlight the features from result1 in the
> current map. To do so, in the same php script, I ran a
> queryByAttribute on the feature IDs to set the correct selection for
> the current session, but I don't know how to send this selection back
> to the widget. I have tried a mapscript drawQuery() and redraw in the
> widget, but this doesn't work.
>  I'm a bit lost as to how I can either set the selection in the php
> script, and somehow updating the map in the widget, or send the
> selection back to the widget and set the selection from there. Could
> anyone please assist me with this?
>  Thanks,
>  Tom van der Putte,
>  The Netherlands
> 
> _______________________________________________
> fusion-users mailing list
> fusion-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fusion-users
> 
> 

-- 
View this message in context: http://n2.nabble.com/Dynamic-selection-tp3828021p3829857.html
Sent from the Fusion Users mailing list archive at Nabble.com.


More information about the fusion-users mailing list