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

Scott L Goodrick sgoodrick at fs.fed.us
Wed Sep 28 09:28:11 EDT 2005


Paul,
Thanks for the help. I found one problem with your suggestion. Evidently
the ExtentsChanged event is triggered during map initiation, thus changing
aLastExtents prior to the zoomToExtents call in MyMapInitialized. The
solution was to add a flag, newMap, that prevents aLastExtents from being
updated.
Thanks again for the help.
Scott

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

__________________________
  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








                                                                           
             Paul Spencer                                                  
             <pspencer at dmsolut                                             
             ions.ca>                                                   To 
                                       Scott L Goodrick                    
             09/19/2005 08:19          <sgoodrick at fs.fed.us>               
             PM                                                         cc 
                                       ka-map-users at lists.maptools.org     
                                                                   Subject 
                                       Re: [ka-Map-users] changing map     
                                       files while persisting map extents  
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




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