Have you run into a strange bug where your ArcGIS map zooms out to show the entire world, even though youâre using SetViewpointAsync with the correct Extent?
We did too.
In a recent project, we were programmatically placing graphic pins on a map using Esriâs ArcGIS Runtime SDK (for .NET MAUI and WinUI). Everything worked fineâââuntil it didnât. Sometimes, after setting the map extent, weâd end up zoomed all the way out to the global view. And weâre talking tiny pins in Berlin, not a world tour.
𧩠The Real Problem#
After some digging, we realized this only happened when:
- All pins shared the same latitude (or longitude)
- We had only one single pin
- Our calculated
Envelopehad zero width or height
When this happens, EnvelopeBuilder.Height or .Width returns 0, and SetViewpointAsync decides:
âNo size? Cool, hereâs the entire planet.â
đ Thanks, but no thanks.
â The Fix: Robust SetExtentAsync#
Hereâs the full method we now use to avoid this pitfall:
| |
đ SEO-style summary (for Google-friendliness):#
If youâre searching for:
- âArcGIS map zooms out too farâ
- âSetExtent not working ArcGISâ
- âArcGIS map shows world even though pins are close togetherâ
- âSetViewpointAsync extent has 0 height or widthâ
âŠthen youâre exactly the person this post is for.
