[Chameleon] Widgets or JSAPI
Jason Fournier
jfournier at dmsolutions.ca
Tue Aug 16 23:12:45 EDT 2005
After some deep Chameleon soul searching I remembered the Customizing
Query Results:
http://chameleon-tiki.maptools.org/tiki-index.php?page=QueryWidgetCustomizingResults
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
Seiple, Timothy E wrote:
> You mention "grabbing these values with [my] onclick when over the map".
> How do I build this onclick event?
>
> Let's say I have an html button in my template that calls a JavaScript
> function. This function would have to somehow focus on the mouse,
> access the map object, and accept onclick event arguments - all from the
> template file.
>
> I see the JSAPI offers the mouseclick property of the CWCApplication.
> Is there an equivalent widget property (e.g. <cwc2 type=MapDHTML
> onclick=getxy() .../>)?
>
>
> -----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 10:21 AM
> To: chameleon at lists.maptools.org
> Subject: Re: [Chameleon] Widgets or JSAPI
>
> Timothy,
>
> I think the cursorpos widget populates the CursorPos_X, CursorPos_Y form
> vars with the current geographic position:
>
> document.formname.CursorPos_X.value
> document.formname.CursorPos_Y.value
>
> (note that these are the cursospos labels)
>
> You could grab these values with your onclick when over the map and pass
> them back to your opener.
>
> I would take a look at the MapNotes widget. It has much of the
> functionality that you going after ... it should shed some light. This
> functionality includes allowing a widget to have control over map
> onclicks, etc.
>
> You shouldn't have to use JSAPI for this functionality - it can be
> achieved with Chameleon in the default mode.
>
> Jay
>
>
>
>
> Seiple, Timothy E wrote:
>
>>I have a web application that requires the user to manually enter
>>coordinate information into a form. I would like to provide a button,
>
>
>>whose on_click event will launch an instance of chameleon with a map
>>that allows the user to click on the map to get the coordinates. The
>>coordinates must then be passed as variables back to the calling form.
>>A remote Oracle DB will provide the spatial data and store the
>>captured coordinate information.
>>
>>Can I do this with Widgets or must I use the JSAPI? I am confused
>>about where I can place scripts. For example, my template uses the
>>Cursorpos Widget to dynamically display {x,y} but how do I capture
>>these in variables that can be passed to other pages? I can see the
>>Chameleon generated JavaScripts and variables in the page source but
>>don't know how to interact with them.
>>
>>I need some help understanding the big picture.
>>
>>Thanks,
>>Tim
>>
>>
>>----------------------------------------------------------------------
>>--
>>
>>_______________________________________________
>>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
> _______________________________________________
> 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
>
--
________________________
Jason Fournier
DM Solutions Group Inc.
jfournier at dmsolutions.ca
www.dmsolutions.ca
613.565.5056 x18
More information about the Chameleon
mailing list