[mapguide-users] gain access to mapFrame divs for javascript drawing?

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Mon Jul 7 16:10:03 EDT 2008


Its hard to say what goes wrong.

First thing is to check that the taskpane (where some code is) is on the 
EXACT same domain as the page serving the map.
Javascript from a page at www.example.com cannot access elements on a 
page from www2.example.com (you need crossdomain, and that is hard to 
get right).

Second, you must take special care of race conditions, you cannot 
control which page loads as the first.
This is especially bad in IE, because the "onload" event from an 
embedded iframe can fire _before_ the hosting page's "onload" event.

The missing "clicked" function is most likely due to some other error, 
which prevents the code defining "clicked" to be defined/initialized.

In firebug, you can set a breakpoint at the line jg = new 
jsGraphics(divID), and step into the code to see what is wrong.

Regards, Kenneth Skovhede, GEOGRAF A/S



Jonathan Manafi skrev:
> I have some javascript that initializes a jsGraphics object when my 
> taskPane loads. Currently, it loads in a div within the taskPane. And 
> before the page loads, I have a document.onkeydown and 
> parent.parent.mapFrame.onkeydown set to a function to capture key 
> presses and then do something. I have gotten the taskPane to recognize 
> mouse movements and mouse clicks that are within the mapFrame, and 
> currently, I use those to draw in the taskPane. I had tried what you 
> said already, and I found the map table and inserted my own div. To 
> test at first, I had put some text inside to see where(if at all) it 
> would show up, and within the 'map' table, it showed up on top of the 
> map. 
>
> However, if I try to access it dynamically, after everything has 
> loaded it seems, I cannot. I have something like
> <code>
> var map;
> var divID;
> var jg;
> .
> .
> .
> function init() {
>   map = parent.parent.document.getElementsByTagName('frame')[1];
>   divID = map.contentDocument.getElementById("mapSpace");
>   jg = new jsGraphics(divID);
> }</code>
>
> And when my code gets executed, the taskPane turns to a blank page, 
> and firebug throws numerous errors when I mouseover the map. The error 
> it seems to be giving me is 'clicked is not defined', which is a 
> global variable that has been declared and initialized.
>
> Am I unable to draw in the mapFrame once it has already been loaded?
>
> Also, somewhat unrelated, is IE7 not able to capture mouse movement or 
> key presses within the mapFrame from the taskPane? It doesn't seem to 
> react the same way as Firefox.
>
> Thanks for any help.
>
>
> Kenneth Skovhede, GEOGRAF A/S wrote:
>> What have you tried to do?
>>
>> If you look at the "ajaxmappane.templ" you can see how the mapFrame 
>> is constructed.
>> It is actually a table, so you may want the item "map" (a cell) or 
>> the item "mapSpace" (a div).
>>
>> As long as you taskpane file and the mapframe is served from the same 
>> server, there should be no problems.
>> Regards, Kenneth Skovhede, GEOGRAF A/S
>>   
>>
>>
>> Jonathan Manafi skrev:
>>> Has anyone ever tried this or have any suggestions?
>>>
>>>
>>> J Manafi wrote:
>>>> Does anyone know how to gain access to divs in the mapFrame from a 
>>>> taskPane php file? I am trying to use the jsGraphics library to 
>>>> draw on top of the map, but I cannot gain access to any div for 
>>>> drawing. I am able to have my mouse movements tracked within the 
>>>> map, but I am currently restricted to drawing within the taskPane.
>>>>
>>>> Has anyone else ever tried this?
>>>> ------------------------------------------------------------------------
>>>> View this message in context: gain access to mapFrame divs for 
>>>> javascript drawing? 
>>>> <http://www.nabble.com/gain-access-to-mapFrame-divs-for-javascript-drawing--tp18098792p18098792.html>
>>>> Sent from the MapGuide Users mailing list archive 
>>>> <http://www.nabble.com/MapGuide-Users-f14845.html> at Nabble.com.
>>>> ------------------------------------------------------------------------
>>>>
>>>> _______________________________________________
>>>> mapguide-users mailing list
>>>> mapguide-users at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>>   
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> mapguide-users mailing list
>>> mapguide-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>>>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> mapguide-users mailing list
> mapguide-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapguide-users
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20080707/9fdcd20b/attachment.html


More information about the mapguide-users mailing list