[Chameleon-dev] [Bug 1068] New: Add query-highlight functionality
to js api
bugzilla-daemon at bugzilla.maptools.org
bugzilla-daemon at bugzilla.maptools.org
Fri May 27 08:26:05 EDT 2005
http://bugzilla.maptools.org/show_bug.cgi?id=1068
Summary: Add query-highlight functionality to js api
Product: Chameleon
Version: 2.2
Platform: PC
OS/Version: Windows 2000
Status: NEW
Severity: enhancement
Priority: P2
Component: Core
AssignedTo: chameleon-dev at lists.maptools.org
ReportedBy: bartvde at xs4all.nl
So we don't forget about this one. Probably TARGET FUTURE.
Hi list,
I have managed to get this running, so I thought I'd share my solution. My
approach needed changes to UpdateMap.php only. Paul/Julien, are there plans for
adding query highlight functionality to UpdateMap.php? Would you guys be
interested in getting this in the Chameleon distro?
My approach does have an assumption: all layers which need to be
query-highlighted need to have a FILTERITEM defined (using an empty FILTER "" in
order to get everything rendered). I like this approach better than a client
having to send the name of a column to the server.
When a node from the treeview is clicked, I run the following javascript (this
is now part of my custom js file included in my app, but could become part of
cwcjsapi.js in the future) :
function CWCRunQuery(layername, filter)
{
CWCDHTML_ShowLayer("ActivityLayer");
aHiddenVars = new Array(3);
aHiddenVars[0] = new Array(2);
aHiddenVars[0][0] = "LAYER_RUN_QUERY";
aHiddenVars[0][1] = "1";
aHiddenVars[1] = new Array(2);
aHiddenVars[1][0] = "LAYER_NAME";
aHiddenVars[1][1] = layername;
aHiddenVars[2] = new Array(2);
aHiddenVars[2][0] = "LAYER_FILTER";
aHiddenVars[2][1] = filter;
// we need to update the map as well
goCWCJSAPI.CallServer("goCWCJSAPI.MapExtentsUpdated()", aHiddenVars);
return true;
}
The changes I did to UpdateMap.php are (adding a selection layer dynamically
which is a copy of the layer which needs to be query-highlighted, and setting
the color to a selection color):
if (isset( $HTTP_FORM_VARS["LAYER_RUN_QUERY"]) &&
$HTTP_FORM_VARS["LAYER_RUN_QUERY"] != "")
{
$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"];
for ($i=0; $i<$oMap->numlayers; $i++)
{
$oLayer = $oMapSession->oMap->GetLayer($i);
if ($oLayer->name == $szLayerName)
{
// copy layer
$oSelectionLayer = ms_newLayerObj( $oMap, $oLayer );
$oSelectionLayer->set( 'name', 'StraGISWebSelection' );
$oSelectionLayer->set( 'template', '' );
$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++)
{
$oStyle = $oClass->getStyle($k);
$oStyle->color->setRGB( 255,255,0 );
}
}
$oSelectionLayer->set( 'status', MS_ON );
}
}
$_SESSION["gszCurrentState"] = $oMapSession->saveState();
}
Best regards,
Bart
Bart van den Eijnden
Syncera-ITSolutions
Postbus 270
2600 AG DELFT
tel.nr.: 015-7512436
email: BEN at Syncera-ITSolutions.nl
>>> "Bart van den Eijnden" <BEN at syncera-itsolutions.nl> 05/17/05 04:41pm >>>
Hi list,
I am faced with the following problem:
I have a treeview next to my MapDHTML. When a node in the treeview is clicked, I
need to highlight the item in the map. I do know how to do this with
PHP/Mapscript (savequery etc.), but I don't know how to do this from the js api
mode.
I can't see any place in the JS API to pass a query and request for an updated map.
Would this require changes to the UpdateMap.php file as well as the cwcjsapi.js
file? Or am I missing something? What would be the best approach for this?
Best regards,
Bart
Bart van den Eijnden
Syncera-ITSolutions
Postbus 270
2600 AG DELFT
tel.nr.: 015-7512436
email: BEN at Syncera-ITSolutions.nl
_______________________________________________
Chameleon mailing list
Chameleon at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/chameleon
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
Please do NOT reply to this email, use the link above instead to
login to bugzilla and submit your comment. Any email reply to this
address will be lost.
More information about the Chameleon-dev
mailing list