Hello,
We are trying to fetch a custom column using 'FeatureSource.CustomColumnFetch' event handler.
For that, we need to detect what is Current Zoom Level and based on that zoom level, we get the currently showing layer and calculate customer data value.
We have multiple layers and shows layers depending on the current zoom level.
The problem we are getting is that Map1.CurrentScale is showing as 'NaN' and Map1.CurrentExtent is returning always the same value.
We tried to calculate current scale using the code here attached.
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;
}
But since the 'Map1.CurrentExtent ' is always the same, the scale value we calculated here is always the same.
I just need to know what is current zoom level the map is showing.
So, is there any reliable way to know it?