Re[mapguide-users] cursive digitizePoint

Kenneth, GEOGRAF A/S ks at geograf.dk
Mon Mar 10 07:42:22 EDT 2008


A quick guess is that the handler code stops the digitizing function 
immediatly after invoking your handler.
You can look in the folder called "viewerfiles" for the code that 
performs the DigtizePoint and callback.
A good starting point is searching for "DigitizePoint" in the file 
"ajaxmapframe.templ".

A very easy and potentially unstable method would be to wrap the 
recursive call in a timer:

window.setTimeout("viewerFrameSet.mapFrame.DigitizePoint(OnPointDigitized);", 100);


It might break occasionally though, because it introduces a race condition.

Regards, Kenneth, GEOGRAF A/S



BruceWeston skrev:
> Hi folks,
>
> I have a small problem with the DigitizePoint function which seems a bit
> odd. I have a map and I want to record the XYs every time the map is
> clicked, without having to press a button first. My initial thought is to
> digitizePoint on the page load and then in my callback handler,
> digitisePoint again so there is recursion. This is the only function that
> will be happening on this map. Here is my Javascript:
>
> <script language="javascript" type="text/javascript">
>         var viewerFrameSet;
>         if(parent.document.getElementById('viewerFrame').contentDocument){
>             //This is for firefox
>             viewerFrameSet =
> parent.document.getElementById('viewerFrame').contentWindow.document.defaultView.parent.frames[0];
>         }else{
>             //This is for IE
>             viewerFrameSet = parent.viewerFrame;
>         }
>         
>         function digitisePoint(){
>             alert('Now pick a point on the map');
>             //Put it into select mode, then digitise point mode
>             viewerFrameSet.mapFrame.ClearSelection();
>             viewerFrameSet.ExecuteMapAction(15);
>             viewerFrameSet.mapFrame.DigitizePoint(OnPointDigitized); 
>         }
>         
>         function OnPointDigitized(point) {
>             document.getElementById("resultArea").value = "X:" + point.X +
> "\nY:" + point.Y;
>             digitisePoint();
>         }
>     </script>
>
> ResultArea is a textbox.
> viewerFrameSet is a variable I use to set the location of the functions.
>
> It works the first time, but then never after that until I click the button
> that runs digitisePoint. Any ideas why OnPointDigitized only runs once? The
> recursion part actually works but the second time it goes into
> digitisePoint()  it doesn't do the OnPointDigitized bit.
>
> I hope this makes sense to people - it's becoming quite confusing.....
>
> Ross
>   


More information about the mapguide-users mailing list