SV: [fusion-users] min/max Zoom scales

Måns Beckman mans.beckman at manandmachine.se
Fri May 23 03:59:08 EDT 2008


Hi, 

I have tried out your tip and it works, but only for my Sheboygan sample data. If I set the minscale, in fusion/MapGuide/php/LoadMap.php, to 100 the map won't zoom in any more when reach a scale that are somewhere between 100 and 200. 
But, this is strange, if I open up another map, same template, in xy-meters or the Swedish coordinate system Sweref99, nothing will happen and I can just keep on zooming in. 
Does anyone got an idea of why?



I still think it is strange that fusion will use the minScale option if I pass it to the open layers map, but the maxScale won't do anything. (Note that in openlayers minScale and maxScale does the opposite of what you think.)

First I thought that it might be an error or something in open layers, so I did some testing with the following code. (Example code from open layers, just the options added by me)
-----------------------------------------
<html>
<head>
  <title>OpenLayers Example</title>
    <script
    src="http://openlayers.org/api/OpenLayers.js"></script>
    </head>
    <body>
      <div style="width:100%; height:100%" id="map"></div>
      <script defer="defer" type="text/javascript">
	  var options = {minScale:5000000, maxScale: 1000000};
        var map = new OpenLayers.Map('map', options);
        var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", 
            "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
        map.addLayer(wms);
        map.zoomToMaxExtent();
      </script>

</body>
</html>
-----------------------------------------
This makes a map that got scales between 5000000 and 1000000, if you try to go outside the boundaries, it will just stop.

If I set "var options = {minScale:5000000, maxScale: 1000000};" to "var options = {maxScale: 1000000};" it will start at full extent and stop the zooming at the scale 1000000, and if I set it to "var options = {minScale:5000000};" it will start at 5000000 and you can zoom in but not out.

So, my conclusion is that somewhere in the code, fusion overwrites the maxScale option, but, and this is what I think I strange, the minScale option is working with fusion. The logical thing would be that either both would work or none would work. The big question is just where does this happen?

Best regards
Måns


-----Ursprungligt meddelande-----
Från: Julien-Samuel Lacroix [mailto:jlacroix at mapgears.com] 
Skickat: den 21 maj 2008 15:25
Till: Måns Beckman
Kopia: fusion-users at lists.osgeo.org
Ämne: Re: [fusion-users] min/max Zoom scales

Hi,

It's probably better for you to set the MinScale/MaxScale directly 
inside MapGuide. Fusion will then set directly the MinScale/MaxScale of 
your map. I'm not sure where the exact place is, but the code say that 
the Layer resource XML contains a ScaleRange.

If you are trying to hack Fusion code to do what you want, then the 
maxScale option is really what you want, but Fusion probably override 
your settings with those from your map. Search for maxscale in 
fusion/MapGuide/php/LoadMap.php

Julien

Måns Beckman wrote:
> Hi All,
> 
>  
> 
> First I'm just going to tell you that I'm not really a programmer, I'm 
> more of a script kiddie, so bare with me.
> 
>  
> 
> The thing is that we got a customer that wants to limit how close the 
> user can zoom in to the map. So I started to have a look and found out 
> that there was something that made the map not zoom in closer than the 
> scale 1:1. So I started do look in the code for what was preventing 
> this, but I didn't find anything in the zoom widgets or in the zoom 
> functions in Map.js. So I started to think there was something in 
> openlayers that made it impossible to zoom in more.
> 
>  
> 
> Ok, so eventually I found out that we can send some options when we 
> initialize the open layers map, and I guess that 1:1 is the default 
> value. http://trac.openlayers.org/wiki/SettingZoomLevels
> 
>  
> 
> So I looked in the code for where we initialize an open layer map and 
> found something on line 98 (this is MGE2009 so the exact lines might 
> have changed). Anyway I thought that I would try to send some more 
> options to the map and changed line 94 from
> 
> var options = {controls: [], fallThrough: true};
> 
> to
> 
> var options = {controls: [], fallThrough: true, minScale: 10000};
> 
>  
> 
> When I reload my map it initializes on scale 1:10000, I can zoom in but 
> not out. I try to change minScale to maxScale, to make the opposite 
> happen. But when I do that, nothing happens in the map, it works like I 
> had sent no extra option at all.
> 
>  
> 
> So, could someone explain this behavior? And could someone tell me how 
> to solve my problem without using fixed zoomscales?
> 
>  
> 
> Best regards
> 
> Måns
> 
>  
> 
> -----------------------------------------------------------
> 
> Måns Beckman
> 
> Man and Machine
> 
> Fabriksgatan 13
> 
> 412 50 Göteborg
> 
> Phone: +46 31 - 762 8182
> 
> Mobile: +46 733 - 38 83 19
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> fusion-users mailing list
> fusion-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/fusion-users

-- 
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/


More information about the fusion-users mailing list