[Chameleon] Widgets or JSAPI (Modifying Customized Query Results)
Jason Fournier
jfournier at dmsolutions.ca
Wed Aug 17 14:28:05 EDT 2005
Your template would contain:
1) goEventManager entry in the onload of your template:
goEventManager.registerForEvent( 'ON_QUERY', 'cbLocation' );
2) You would place a link widget (javascript, not href) in your template
that refers to cbLocation as the js callback.
3) cbLocation would be somewhere inside script tags in your template:
<script>
function cbLocation()
{
var nX = document.formname.CursorPos_X.value;
var nY = document.formname.CursorPos_Y.value;
window.opener.document.formname.nXLocation.value = nX;
window.opener.document.formname.nYLocation.value = nY;
self.close();
}
</script>
4) Place CursorPos widgets in the template somwhere.
The order of events would be:
1) User clicks a button in your regular html application that launches a
chameleon instance/app.
2) User clicks on the 'select location' button (ie, the link widget you
put in the template). Alternatively I believe you can make this button
selected by default.
3) User selectes location on the map.
4) The callback (cbLocation) gets fired because you've registeres
ON_QUERY in your onload.
5) cbLocation grabs the location from the CursorPos widget and pass
those variables back to the opener (your other app).
6) Chameleon closes itself.
I don't think the ON_QUERY has made it to the documentation just yet. I
happen to know about it because I helped put it there.
Jay
Seiple, Timothy E wrote:
> I'm starting to see the light... For clarification though:
>
> The order of events will be 1) Use the customized Query widget to get
> and store the {x,y} in variables rather than display results. Then use
> a Link widget to get back to the calling application, taking along the
> x,y variables somewhere in the http header. Is this right?
>
> I did not see ON_QUERY in the event details section of the chameleon
> documentation. How did you know about this event? Are there more that
> I am missing?
>
>
> -----Original Message-----
> From: chameleon-bounces at lists.maptools.org
> [mailto:chameleon-bounces at lists.maptools.org] On Behalf Of Jason
> Fournier
> Sent: Tuesday, August 16, 2005 8:13 PM
> To: chameleon at lists.maptools.org
> Subject: Re: [Chameleon] Widgets or JSAPI
>
> After some deep Chameleon soul searching I remembered the Customizing
> Query Results:
>
> http://chameleon-tiki.maptools.org/tiki-index.php?page=QueryWidgetCustom
> izingResults
>
>
> This is a relatively simple method of accomplishing your task without
> having to create a widget. Basically, you will have a link widget
> which, when used, gets intercepted by the Global Event Manager. At this
> point you can call anything you want in javascript.
>
> You shouldn't have to get e or event for this IF you include the
> CursorPos widget (for X & Y). In your js callback you will be able to
> get the coordinates via the form variables:
>
> document.formname.CursorPos_X.value
> document.formname.CursorPos_Y.value
>
> So, let's say that in your body onload you specify:
>
> goEventManager.registerForEvent( 'ON_QUERY', 'cbLocation' );
>
> so that when you perform a 'query' the following gets called:
>
> function cbLocation()
> {
> var nX = document.formname.CursorPos_X.value;
> var nY = document.formname.CursorPos_Y.value;
> window.opener.document.formname.nXLocation.value = nX;
> window.opener.document.formname.nYLocation.value = nY;
> self.close();
> }
>
> Although I haven't tested this code it should work. CursorPos_X and
> CursorPos_Y do all the work for you in getting the coords. You just
> have to reference them and pass them back to your opener.
>
> Make sense?
>
> Jay
>
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
>
--
________________________
Jason Fournier
DM Solutions Group Inc.
jfournier at dmsolutions.ca
www.dmsolutions.ca
613.565.5056 x18
More information about the Chameleon
mailing list