ThinkGeo.com    |     Documentation    |     Premium Support

Initial map extent is shifted from RectangleShape setting in Form load

Hello, Support team,

The map base layer is Openstreetmap and I set the zoomlevel to match the OSM layer,
In WinForm.load event, I set the map extent by defining a RectangleShape:

               Map.ZoomLevelSet = New OpenStreetMapsZoomLevelSet  

            Map.CurrentExtent = New RectangleShape (-14269840.2432911,5728482.31917297,-7323260.48929205,3448830.09004371)
                 Map.ZoomToScale(18489298)      'If I don't set scale, the map will zoom out and snap to next zoom level. 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      The map first load is not covering target RectangleShape, but shifted to (-13183825.6620321,5513236.18595046,-8409275.07055107,3664076.22326622) and not centered to US. Please see attached screen shot. "ExtentOff-at_FormLoad.png"

After initial loading, if I run the same Extent and scale level and refresh map from a "Full Extent" button control, the map is centered correctly. Screen shot "ExtentCorrect-AfterClickFullExtent.png"

Please see map Control setting from "WinFormMapSetting.png"

How to set the initial extent to get map centered to US and snap to proper zoom-level?

Thank you.
Sunshine<img src="/uploads/default/original/3X/c/7/c773af5fcd38164afdc8e27e67f663bfbca40991.png" width="586" height="499"><img src="/uploads/default/original/3X/8/e/8ec6105ae5214353c7941ce433daa800389d5e04.png" width="690" height="243"><img src="/uploads/default/original/3X/9/7/97814c1d3ec57923b2b73455320e8f08fb1b9bd7.png" width="690" height="245">

Hi Sunshine,

Please set the ZoomLevelSnapping property of WinformMap to SnapToClosest, like the image shows.

Thanks,
Peter

Hi Yang,

The reason is that Map Suite does an extent re-calculation after you set the currentExtent to make sure the real extent matches the size of map, thus we don’t see a map which is screwy. Peter’s idea is good, but please reminder that the map doesn’t have Zoom Levels, Anyway please take a try. Another workaround is that you can position the map by Center and CurrentScale, it may avoid this problem.

Hope it helps.

Thanks,
Johnny

@Peter, thank you for the suggestion. I see the option of “SnapToClosest” for zoomLevelSnapping after upgrade to Desktop V9.0.464.0. The setting to “SnapToClosest” did not make difference for initial extent, but greatly affect Panning. When ZoomLevelSnapping is not None, Panning will not preserve current zoom view but auto jump to a preset level. I will discuss with our users and set this accordingly.

@Johnny, very appreciate for the additional info regarding the zoom extent calculation. Set center and currentScale works better than currentExtent. I managed to adjust currentExtent coordinates X shifted to the west by same amount and get the map centered as expected.

Great! Yang, anything problemed please feel free to let us know.

Thanks,
Johnny