# Map1.CurrentScale is NaN and Map1.CurrentExtent is always the same

**URL:** <https://community.thinkgeo.com/t/map1-currentscale-is-nan-and-map1-currentextent-is-always-the-same/6074>\
**Category:** WebForms\
**Created:** [December 21, 2011, 11:26am UTC](https://community.thinkgeo.com/t/map1-currentscale-is-nan-and-map1-currentextent-is-always-the-same/6074 "2011-12-21T11:26:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shwe](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/ed8c4c/32.png) [@shwe](https://community.thinkgeo.com/u/shwe)\
**Post date:** [December 21, 2011, 11:26am UTC](https://community.thinkgeo.com/t/map1-currentscale-is-nan-and-map1-currentextent-is-always-the-same/6074/1 "2011-12-21T11:26:26Z")

</div>

Hello,

&nbsp;We&nbsp;are&nbsp;trying&nbsp;to&nbsp;fetch&nbsp;a&nbsp;custom&nbsp;column&nbsp;using&nbsp;'FeatureSource.CustomColumnFetch'&nbsp;event&nbsp;handler.

&nbsp;For&nbsp;that,&nbsp;we&nbsp;need&nbsp;to&nbsp;detect&nbsp;what&nbsp;is&nbsp;Current&nbsp;Zoom&nbsp;Level&nbsp;and&nbsp;based&nbsp;on&nbsp;that&nbsp;zoom&nbsp;level,&nbsp;we&nbsp;get&nbsp;the&nbsp;currently&nbsp;showing&nbsp;layer&nbsp;and&nbsp;calculate&nbsp;customer&nbsp;data&nbsp;value.

&nbsp;We&nbsp;have&nbsp;multiple&nbsp;layers&nbsp;and&nbsp;shows&nbsp;layers&nbsp;depending&nbsp;on&nbsp;the&nbsp;current&nbsp;zoom&nbsp;level.

&nbsp;The&nbsp;problem&nbsp;we&nbsp;are&nbsp;getting&nbsp;is&nbsp;that&nbsp;Map1.CurrentScale&nbsp;is&nbsp;showing&nbsp;as&nbsp;'NaN'&nbsp;and&nbsp;Map1.CurrentExtent&nbsp;is&nbsp;returning&nbsp;always&nbsp;the&nbsp;same&nbsp;value.

&nbsp;We&nbsp;tried&nbsp;to&nbsp;calculate&nbsp;current&nbsp;scale&nbsp;using&nbsp;the&nbsp;code&nbsp;here&nbsp;attached.

&nbsp;

` public double GetCurrentScale()        {            //ShapeFileFeatureLayer stateLayer = GetStateLayer();            //RectangleShape boundingBox = GetFullExtent(stateLayer);            RectangleShape boundingBox = Map1.CurrentExtent;            double resolution = Math.Max(boundingBox.Width / mapWidthInPixel, boundingBox.Height / mapHeightInPixel);            double returnScale=0.0;            double ratio = double.NaN;            switch (Map1.MapUnit)            {                case GeographyUnit.DecimalDegree: ratio = 419976384; break;                case GeographyUnit.Feet: ratio = 1152; break;                case GeographyUnit.Meter: ratio = 3779.5296; break;                //default: ratio = double.NaN;            }            if (!double.IsNaN(ratio))            {                returnScale = ratio * resolution;            }            return returnScale;        }`

&nbsp;But&nbsp;since&nbsp;the&nbsp;'Map1.CurrentExtent&nbsp;'&nbsp;is&nbsp;always&nbsp;the&nbsp;same,&nbsp;the&nbsp;scale&nbsp;value&nbsp;we&nbsp;calculated&nbsp;here&nbsp;is&nbsp;always&nbsp;the&nbsp;same.  
  
&nbsp;  
  
&nbsp;I&nbsp;just&nbsp;need&nbsp;to&nbsp;know&nbsp;what&nbsp;is&nbsp;current&nbsp;zoom&nbsp;level&nbsp;the&nbsp;map&nbsp;is&nbsp;showing.&nbsp;  
  
&nbsp;So,&nbsp;is&nbsp;there&nbsp;any&nbsp;reliable&nbsp;way&nbsp;to&nbsp;know&nbsp;it?

&nbsp;

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [December 21, 2011, 4:36pm UTC](https://community.thinkgeo.com/t/map1-currentscale-is-nan-and-map1-currentextent-is-always-the-same/6074/2 "2011-12-21T16:36:50Z")

</div>

Hello&nbsp;shwe,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;post&nbsp;and&nbsp;code,&nbsp;the&nbsp;code&nbsp;have&nbsp;no&nbsp;problem,&nbsp;and&nbsp;I&nbsp;have&nbsp;test&nbsp;it&nbsp;in&nbsp;how&nbsp;do&nbsp;I&nbsp;samples,&nbsp;we&nbsp;can&nbsp;get&nbsp;different&nbsp;extent&nbsp;each&nbsp;time,&nbsp;could&nbsp;you&nbsp;please&nbsp;provide&nbsp;a&nbsp;self-contained&nbsp;sample&nbsp;can&nbsp;recreate&nbsp;your&nbsp;problem?&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary

---

<div class="post-metadata">

**Author:** ![shwe](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/ed8c4c/32.png) [@shwe](https://community.thinkgeo.com/u/shwe)\
**Post date:** [December 22, 2011, 10:14am UTC](https://community.thinkgeo.com/t/map1-currentscale-is-nan-and-map1-currentextent-is-always-the-same/6074/3 "2011-12-22T10:14:01Z")

</div>

Did&nbsp;you&nbsp;try&nbsp;from&nbsp;'CustomColumnFetch'&nbsp;event?&nbsp;I&nbsp;am&nbsp;getting&nbsp;problem&nbsp;in&nbsp;that&nbsp;event&nbsp;hanlder&nbsp;code.

I&nbsp;have&nbsp;also&nbsp;tried&nbsp;to&nbsp;get&nbsp;'Map1.CurrentScale'&nbsp;from&nbsp;'OnExtentChanged'&nbsp;event&nbsp;hander,&nbsp;too.

But,&nbsp;Map1.CurrentScale&nbsp;value&nbsp;in&nbsp;OnExtentChanged&nbsp;event&nbsp;handler&nbsp;is&nbsp;slightly&nbsp;different&nbsp;(&nbsp;some&nbsp;decimal&nbsp;places)&nbsp;with&nbsp;actual&nbsp;drawing.&nbsp;I&nbsp;came&nbsp;to&nbsp;&nbsp;notice&nbsp;that&nbsp;(by&nbsp;some&nbsp;reason&nbsp;i&nbsp;don't&nbsp;know),&nbsp;sometime,&nbsp;Map1.CurrentScale&nbsp;value&nbsp;has&nbsp;valid&nbsp;value&nbsp;(not&nbsp;NaN)&nbsp;&nbsp;in&nbsp;'CustomerColumnFetch'&nbsp;event&nbsp;handler&nbsp;and&nbsp;I&nbsp;compared&nbsp;these&nbsp;two&nbsp;values.

&nbsp;Please&nbsp;note&nbsp;that::&nbsp;We&nbsp;use&nbsp;this&nbsp;scale&nbsp;value&nbsp;to&nbsp;know&nbsp;the&nbsp;currenly&nbsp;showing&nbsp;layer&nbsp;of&nbsp;the&nbsp;overlay&nbsp;and&nbsp;so&nbsp;that&nbsp;we&nbsp;can&nbsp;calculate&nbsp;the&nbsp;custom&nbsp;colum&nbsp;value.

&nbsp;If&nbsp;you&nbsp;have&nbsp;other&nbsp;way&nbsp;to&nbsp;know&nbsp;the&nbsp;currently&nbsp;showing&nbsp;layer&nbsp;from&nbsp;CustomColumnFetch&nbsp;event,&nbsp;please&nbsp;let&nbsp;me&nbsp;know,&nbsp;too.

thank&nbsp;you

shwe

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [December 22, 2011, 3:09pm UTC](https://community.thinkgeo.com/t/map1-currentscale-is-nan-and-map1-currentextent-is-always-the-same/6074/4 "2011-12-22T15:09:46Z")

</div>

Hello&nbsp;shwe,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Is&nbsp;that&nbsp;possible&nbsp;you&nbsp;can&nbsp;provide&nbsp;this&nbsp;sample?&nbsp;With&nbsp;your&nbsp;sample&nbsp;I&nbsp;can&nbsp;easily&nbsp;find&nbsp;the&nbsp;problem&nbsp;in&nbsp;the&nbsp;code&nbsp;or&nbsp;bug&nbsp;in&nbsp;the&nbsp;core.&nbsp;  
&nbsp;&nbsp;  
&nbsp;And&nbsp;I&nbsp;can&nbsp;help&nbsp;you&nbsp;fit&nbsp;your&nbsp;requirement&nbsp;by&nbsp;your&nbsp;sample.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Gary
