[ka-Map-users] Switching maps, same scale

Sten-Helge Henriksen stenhh at gossipwall.com
Fri Mar 31 03:09:32 EST 2006


Hi there!

Your solution to my question took a couple of minutes to implement. It
worked, and I am now able to change map without loosing center or scale.
Thanks.

Ka-Map seems to have a lot of features built in whiteout being activated.
Is there somewhere any documentation which describe the architecture of
Ka-map?

Sten-Helge Henriksen

> Sten-Helge,
>
> its possible but requires a little bit of code to make it happen.
>
> The first thing you need to do is intercept the call to mySetMap in
> the <select> in index.html.  You can do this by modifying the
> <select> to call your own function or my modifying mySetMap in
> startUp.js.
>
> I'll describe modifying mySetMap in startUp.js.  Currently this
> function reads:
>
> function mySetMap( name ) {
>      myKaMap.selectMap( name );
> }
>
> To get the new map to load at the same center and scale as the
> previous map, we have to pre-set the extents of the new map before
> selecting it (um, wouldn't it be nice if you could pass new extents
> or centerpoint and scale to selectMap! - I've added this to kaMap.js
> in cvs).
>
> Looking in kaMap.js at selectMap, if the new map has a center point
> ad scale set in an array aZoomTo then it will apply it right away.
> If aZoomTo is not set, it will use the currentExtents array.  So all
> we need to do is grab the current extents or current center and scale
> and apply that to the new map before selecting it.  Center point and
> scale is more accurate since kaMap will often zoom out one scale to
> show given extents (probably a rounding error somewhere).  So the
> modified mySetMap is:
>
> function mySetMap( name ) {
>      var scale = myKaMap.getCurrentScale();
>      var centerX = (extents[0] + extents[2])/2;
>      var centerY = (extents[1] + extents[3])/2;
>      myKaMap.aMaps[name].aZoomTo = [centerX, centerY, scale];
>      myKaMap.selectMap( name );
> }
>
> if you are using the cvs version after my commit this morning, you
> can modify this as:
>
> function mySetMap( name ) {
>      var scale = myKaMap.getCurrentScale();
>      var extents = myKaMap.getGeoExtents();
>      var centerX = (extents[0] + extents[2])/2;
>      var centerY = (extents[1] + extents[3])/2;
>      myKaMap.selectMap( name, [centerX, centerY, scale] );
> }
>
> Cheers
>
> Paul
>
> On 30-Mar-06, at 2:25 AM, Sten-Helge Henriksen wrote:
>
>> Hi list!
>>
>> In my Ka-Map setup I have two types of maps, raster and vector,
>> which are
>> covering the same geographical area.
>> When I am using one map type at a low scale and want to switch over
>> to the
>> other map type, I have to start all over again and manually change the
>> scale to the same as on the previous map.
>> Is there a way to keep those to maps at the same scale? That is
>> when the
>> user switch map the same scale is maintained. And if so, how?
>>
>> Sten-Helge Henriksen
>> _______________________________________________
>> 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