[mapguide-users] AJAX viewer zoom slider

Jason Birch Jason.Birch at nanaimo.ca
Fri Apr 7 14:44:19 EDT 2006


Thanks again.

I like the second method;  this kind of function hooking would be a
great addition to the developers guide or possibly the viewer API,
including examples of how to use it from the parent frame and others
(like the task frame).

Jason

-----Original Message-----
From: Alain Lebatard [mailto:alain.lebatard at autodesk.com] 
Sent: Friday, April 07, 2006 11:09
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] AJAX viewer zoom slider

Unfortunately onload is not a good place for this because the scales and
other data are initialized only after the onload event of the map frame
complete, so chances are that onload in the parent will be called before
the map is finished initializing. 

However there is a variable 'mapInit' which is set to true after the map
is initialized. You could watch for this variable and do your own
initialization when it becomes true. The following snippet would do

var initTimer = setInterval(watchInitialized, 200);
		
function watchInitialized () {
    try {
	if(mapFrame.mapInit) {
	   clearInterval(initTimer);
	   // .. Now the map is initialized. Can change the scales.
      }
   }
   catch(Exception) {}
}

You'll just need to change the reference to mapFrame according to the
location your script is running from.

There is an alternative way to achieve this and it's to hook the
OnMapLoaded() method in the main frame. This method is called by map
frame to notify that the map is initialized. You could do something like
this (once again change the reference accordingly):

var originalMethod = mainFrame.OnMapLoaded; mainFrame.OnMapLoaded =
MyOnMapLoadedHandler;


function MyOnMapLoadedHandler() {
   // .. Now the map is initialized. Can change the scales
   
   // don't forget to call the original method, the main frame relies
   // on call to OnMapLoaded() by the map frame
   originalMethod ();
}


Alain

-----Original Message-----
From: Jason Birch [mailto:Jason.Birch at nanaimo.ca]
Sent: Friday, April 07, 2006 10:50 AM
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] AJAX viewer zoom slider

Thanks Alain.

Should I be placing this in an onload handler for the main frame, or is
there an event that fires when the map is initialized that I can respond
to?  The developer guide seems to be focussed mostly on interacting with
the task frame; I couldn't figure it out from that.

Jason


-----Original Message-----
From: Alain Lebatard [mailto:alain.lebatard at autodesk.com]
Sent: Friday, April 07, 2006 09:39
To: users at mapguide.osgeo.org
Subject: RE: [mapguide-users] AJAX viewer zoom slider

Jason,

You can workaround this for now by setting the 'scales' array to a new
value after the map is initialized. For example this will change the
slider to zoom between scales 1:2000 and roughly 1:300000

    scales = new Array();
    scale = 2000;
    for(var i=0; i < 20; i++) {
        scales[i] = scale;
        scale *= 1.3;
    }

    mapFrame.scales = scales;

You're free to define the number of scales in the array to make the
slider smoother and to define the increment between scales.

Alain

-----Original Message-----
From: Jason Birch [mailto:Jason.Birch at nanaimo.ca]
Sent: Friday, April 07, 2006 8:12 AM
To: users at mapguide.osgeo.org
Subject: [mapguide-users] AJAX viewer zoom slider

Is it just me, or does having a zoom slider where the top 1/3 is
dedicated to scales greater than 1:1 not make any sense?  This appears
to be the case in the maps that I have made that don't have base layers.
 
The slider function itself appears to use a pretty good algorithm to
zoom progressively, but I think that it might be more useful if:
 - It was integer-based, and/or
 - It was possible to specify min/max scales for a given map
 
I put in a defect report for this a while back:
https://mapguide.osgeo.org/servlets/Scarab?id=MG146
 
In the meantime, can anyone suggest a workaround?
 
Thanks,
Jason

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
For additional commands, e-mail: users-help at mapguide.osgeo.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
For additional commands, e-mail: users-help at mapguide.osgeo.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
For additional commands, e-mail: users-help at mapguide.osgeo.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
For additional commands, e-mail: users-help at mapguide.osgeo.org






More information about the Mapguide-users mailing list