[ka-Map-users] changing map files while persisting map extents

Paul Spencer pspencer at dmsolutions.ca
Mon Sep 19 20:19:11 EDT 2005


track the extents by listening to KAMAP_EXTENTS_CHANGED and use the  
last extents when you receive a KAMAP_MAP_INITIALIZED ...

var aLastExtents = null;
var myKaMap = null;

function myOnLoad()
{
     myKaMap = new kaMap( 'viewport' );
     myKaMap.registerForEvent( KAMAP_EXTENTS_CHANGED, null,  
myExtentsChanged );
     myKaMap.registerForEvent( KAMAP_MAP_INITIALIZED, null,  
myMapInitialized );
     ...
}

function myExtentsChanged( eventID, extents )
{
     aLastExtents = extents;
}

function myMapInitialized( )
{
     if (aLastExtents)
     {
         myKaMap.zoomToExtents( aLastExtents[0], aLastExtents[1],
                                aLastExtents[2], aLastExtents[3] );
     }
}

If you find that the scale sometimes changes, it is likely a problem  
with zoomToExtents and rounding problems ... try tracking center  
point and scale instead (hint center x = (min x + max x) / 2 and  
KAMAP_SCALE_CHANGED)

Cheers

Paul

On 19-Sep-05, at 5:02 PM, Scott L Goodrick wrote:

>
> First, let me say great work on ka-map!!!
> Now for the question. Any ideas what I would need to change to  
> persist my
> map extents/zoom when changing mapfiles??
> Thanks,
> Scott
> __________________________
>   Scott L. Goodrick, Ph.D.
>   Research Meteorologist
>   USDA Forest Service
>   Southern Research Station - RWU 4104
>   320 Green Street
>   Athens, GA 30602
>   Phone: 706-559-4237
>
>
>
>
>
>
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users
>

+-----------------------------------------------------------------+
|Paul Spencer                           pspencer at dmsolutions.ca   |
+-----------------------------------------------------------------+
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+






More information about the ka-Map-users mailing list