Hi Rob,
When you call Map1.ZoomTo function, this won’t works until map refresh. So you can add a client function like Map1_Click and get the Map1.CurrentExtent in this function.
Because we have “snap” in map, you can calculate the extent by following function:
(Note, because we cannot get ActualHeight and ActualWidth of map control before postBack if you set them as something like 100%, so you can only use it after postback also, if you set actual width or height of map, you can call it before postBack)
Dim dotsPerInch As Integer = 96
Public Function GetExtentByScaleAndCenterPoint(ByVal scale As Double, ByVal centerPointShape As PointShape, ByVal screenWidth As Single, ByVal screenHeight As Single, ByVal mapUnit As GeographyUnit)
Dim resolution As Double = scale / (GetInchesPerUnit(mapUnit) * dotsPerInch)
Dim extentWidth As Double = resolution * screenWidth
Dim extentHeight As Double = resolution * screenHeight
Dim upperLeftPointShape As PointShape = New PointShape(centerPointShape.X - extentWidth / 2, centerPointShape.Y + extentHeight / 2)
Dim lowerRightPointShape As PointShape = New PointShape(centerPointShape.X + extentWidth / 2, centerPointShape.Y - extentHeight / 2)
Return New RectangleShape(upperLeftPointShape, lowerRightPointShape)
End Function
Private Function GetInchesPerUnit(ByVal mapUnit As GeographyUnit) As Double
Dim inchesPerUnit As Double = 0
Select Case mapUnit
Case GeographyUnit.DecimalDegree
inchesPerUnit = 4374754
Case GeographyUnit.Feet
inchesPerUnit = 12
Case GeographyUnit.Meter
inchesPerUnit = 39.3701
Case GeographyUnit.Unknown
Case Else
End Select
Return inchesPerUnit
End Function
Any question please let us know.
Regards,
Don