ThinkGeo.com    |     Documentation    |     Premium Support

Map1.MapUnit = GeographyUnit.Unknown

Hi,


I have a project where I want to display a jpg image of a building in the map control.  I have created a world file so it will load correctly but I'm having a problem because I need to zoom way in and the map control wont' let me zoom in that far.  I thought this was probably because I had my map unit in meters and it has some limit on how far you can zoom in.  I changed it to unknown to see what that would do and it raised the following error:


"The value for the enumeration is not on the val id values.  Parameter name : mapUnit"


When would i use the GeogrpahyUnit.Unkown?  And what map unit should I use for my case and to solve the problem where I can zoom way in.


Thanks!


 



Clint, 
  
 The smallest scale we can show on map is around 840:1, which means for a 8.4 meter length road, we can represent it with 1 centimeter length line at most, that’s enough for almost all the cases, but maybe not for your case where you want to show a building. We will see if we need to change this limit to let people zoom in more. 
  
 GeopraphyUnit.UnKnown is a unit you should never use. The map data only makes sense with a unit, otherwise map control will have no idea what the current zoom level is or what the length between 2 points is. That’s why inputting GeopraphyUnit.UnKnown to any api throws an exception.  
  
 Ben. 


Ben, 
  
 Thanks for the answer!  
  
 If the GeographyUnit.Unkwon is never suppposed to be used why is it an option in the enumeration? 
  
 I know there may not be a real reason but I thought I would ask anyways :)   
  
  
 Thanks! 
  
  
  
  


Clint, 
  
 In fact, the reason we introduce this is to remind developers to set the MapUnit property. It is supposed that we set the MapUnit to Unknown by default, so developers will get an exception if they do not set it explicitly to a meaningful unit. What we do now is not so great, as we use DecimalDegrees by default, which will work fine with most cases so usually people don’t realize every data should have a unit and they already set it. We will correct this in the future and you can see generally with this unit, we want to force people to set the unit explicitly so they can have a better understanding what’s going on. 
  
 Ben. 


Thanks Ben, that answers my question!

My pleasure, Clint.  :)

Hi, 
  
 Do you know if the next beta refresh will remove the limit 840:1, and allow users to zoom in further in my example of displaying a building’s floor plan? 
  
 Thanks!

Clint, 
  
 You can accomplish it with the following javascript code. 
  
 
<script type="text/jscript">
        var OnMapCreating = function(map){
            map.maxScale = null;
            map.minScale = 100000000;
        }
    </script>
 
  
 MinScale stands for the mininum scale the map can display, default value is 1:590591790, which means you cannot zoom out further than that. Similarly, MaxScale stands for the max scale map can display, the default value is 1: 1126, which means you cannot zoom in any further than that. 
  
 So here you can change the default scales in the above code. If you set the maxScale to null, the scales of zoomBar will only depend on the minScale you set as following: 
  
  ZoomBar.Level01.Scale minScale (as you set) 
  ZoomBar.Level02.Scale minScale / 2 
  ZoomBar.Level03.Scale minScale / 4 
 ……  
  ZoomBar.Level (n).Scale minScale / 2^(n-1) 
  
 So with the code above, you can zoom in further, and the scales for your ZoomBar will also change. 
  
 PS: this setting will not affect the 3rd part overlays (GoogleMap, VirtualEarth, YahooMap). 
  
 Ben.