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.
