FW: [Chameleon] Query widget to display only "selectedLayers"

McGraw, Joanne mcgrawj at AGR.GC.CA
Fri Sep 2 09:50:55 EDT 2005


I'm just posting the solution to the list in case anyone else runs into
the same problem adding a new NAV_CMD to interact with the MapDHTML.

If I find any problems occurring as a result of making the change to
MapDHTML.js' MapWgetMouse(e) function described below, I'll re-submit.

Cheers,
jtm

-----Original Message-----
From: Paul Spencer [mailto:pspencer at dmsolutions.ca] 
Sent: Friday, September 02, 2005 8:31 AM
To: McGraw, Joanne
Subject: Re: [Chameleon] Query widget to display only "selectedLayers"

Joanne,

this sort of makes sense, but not fully.  I think I am in the same boat 
as you.  Without taking some time to walk through the code in a 
debugger, I don't think I can shed any more light on it.

I am not particularly happy with the way MapDHTML has to be changed to 
accomodate new widgets that interact with the map and I will be 
modifying this at some point (although not for the next release I
think).

Cheers

Paul

McGraw, Joanne wrote:
> Paul,
> The problem was fixed by adding a check for:
gMapDHTMLForm.NAV_CMD.value
> == "QUERY_SELECTED" to the list of other tools in the MapWgetMouse(e)
> function.
> 
> I now have an if block in there that looks like this (note the
> "QUERY_SELECTED"):
> 
>     if((gMapDHTMLForm.NAV_CMD != null) &&
>     (gMapDHTMLForm.NAV_CMD.value == "" ||
>     gMapDHTMLForm.NAV_CMD.value == "PAN_MAP" ||
>     gMapDHTMLForm.NAV_CMD.value == "RULER" ||
>     gMapDHTMLForm.NAV_CMD.value == "QUERY" ||
>     gMapDHTMLForm.NAV_CMD.value == "QUERY_SELECTED" ||
>     gMapDHTMLForm.NAV_CMD.value == "ADD_MAPNOTE" ||
>     gMapDHTMLForm.NAV_CMD.value == "EDIT_MAPNOTE" ||
>     gMapDHTMLForm.NAV_CMD.value == "ROI_TOOL" ||
>     gMapDHTMLForm.NAV_INPUT_SUBMIT.value == '0'))
>         return true;
> 
> It was not necessary to add the item to similar if blocks in
> MapWchkMouseUp or MapWmapTool.
> 
> What I don't understand is how it would get through the fact that
> QUERY_SELECTED wasn't part of the if condition in MapWgetMouse(e) and
> work as expected sometimes. I'm a little leery of putting this info
re:
> how I 'fixed' my problem until I understand better how doing this
fixed
> my it and what the ramifications of making a change like this might
be.
> 
> Can you throw any light on that?
> 
> Cheers,
> jtm
> 
> 
> 
> McGraw, Joanne wrote:
> 
>>Hello,
>>
>>Me again; different problem.
>>
>>My application is supposed to have functionality to Query all layers
> 
> and
> 
>>to Query only the currently selected layers as well (set using the
>>SelectLayers widget). The results of these queries are displayed in an
>>IFrame, whose name is passed in through the iframename attribute. 
>>
>>In order to do this, I altered the Query widget:
>>
>>1. To optionally accept another attribute indicating that only the
>>selectedLayers' values should be displayed and set the NavCommand
> 
> based
> 
>>on that: $this->SetNavCommand("QUERY_SELECTED"); // vs. "QUERY" for
> 
> all
> 
>>layers
>>
>>2. In GetJavascriptInitFunctions, I am registering a new event id:
>>$aResult['NLWISQuerySelectedRegisterEvent'] =
>>"goEventManager.registerEventID( 'ON_QUERY_SELECTED' );\n";
>>
>>3. In GetJavascriptFunctions, I have essentially duplicated the two
>>Javascript functions NLWISQueryWMouseClick and NLWISQueryWMouseMove to
>>create two new Javascript functions NLWISQuerySelectedWMouseClick and
>>NLWISQuerySelectedWMouseMove.
>>
>>a. The NLWISQuerySelectedWMouseMove function checks that the NAV_CMD
>>equals "QUERY_SELECTED" and then sets the mouseup event to the new
>>function: "document.onmouseup = NLWISQuerySelectedWMouseClick;" 
>>
>>b. The NLWISQuerySelectedWMouseClick appends the selected layers to
> 
> the
> 
>>URLs provided: "&selectedLayers=" +
>>{$this->mszHTMLForm}.SELECTED_LAYERS.value (so those values are
>>available to the Query's PHTML) and triggers the "ON_QUERY_SELECTED"
>>event: goEventManager.triggerEvent( 'ON_QUERY_SELECTED', nX, nY );
>>
>>
>>Now, to my problem.
>>
>>I click on the NavButton to indicate that I would like to Query
> 
> Selected
> 
>>Layers only and click on the map. More often than not, the mouseup
> 
> event
> 
>>does not trigger the running of the NLWISQuerySelectedWMouseClick
>>function. It will occasionally; and, when it does, the results
> 
> displayed
> 
>>in the iframe are correct. It's just that there doesn't seem to be any
>>rhyme or reason to when it decides to run the function and when not.
>>
>>I've tried clicking a specific numbers of times, on specific parts of
>>the map, using single and double-clicks, clicking once and waiting a
>>minute (in case there's some weird lag time happening). There does not
>>appear to be any pattern to when the function runs and when it
> 
> doesn't.
> 
>>It seems as though the mouseup event is somehow erroneous 90% of the
>>time and is being consumed before it actually calls the
>>NLWISQuerySelectedWMouseClick function.
>>
>>The same Query widget works exactly as expected, on every click, when
> 
> I
> 
>>am not trying to limit the query to only those selected. 
>>
>>Is there a piece to this puzzle that I am missing somewhere? Is there
>>something else I need to add to my code or to Chameleon to get this to
>>go?
>>
>>Cheers,
>>jtm
>>
>>
>>_______________________________________________
>>Chameleon mailing list
>>Chameleon at lists.maptools.org
>>http://lists.maptools.org/mailman/listinfo/chameleon
>>
> 
> 

-- 
+-----------------------------------------------------------------+
|Paul Spencer                           pspencer at dmsolutions.ca   |
+-----------------------------------------------------------------+
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+



More information about the Chameleon mailing list