Forum Discussion
Azure Maps – Dynamic zoom when filtering polygons from a single GeoJSON?
- 9 months ago
Hello Anonymous,
This behaviour is expected because the Azure Maps visual calculates the zoom level based on the full extent of the GeoJSON file, even when the data is filtered in Power BI. Unfortunately, there is currently no native option to automatically recalculate the extent only for the visible data after filtering.Recommended Approaches
1. Split the GeoJSON into multiple files (recommended)
Instead of using a single GeoJSON containing all areas, create a table with a column that holds the specific GeoJSON for each area. When the user selects an area in the slicer, the visual will load only the corresponding file, automatically adjusting the zoom.This can be achieved in Power Query:- Import the GeoJSON.
- Expand the polygons and create a column with the individual JSON for each area.
- Link this table to the slicer.
f this answer was helpful in any way, I would be pleased to receive a thumbs-up, as well as the satisfaction of seeing a DAX measure work for the first time without needing yet another FILTER.
Please mark it as the accepted solution. This helps other community members find the quickest path and saves them from another endless loop 🌀.
Today Azure Maps in Power BI cannot recalculate the zoom extent only from the filtered polygons of a single GeoJSON reference layer, so your behavior is expected.
What you can do
1. Use a data‑bound layer instead of a static GeoJSON reference layer
Import the GeoJSON into your model (Get data → JSON), expand into a table with a column for the polygon geometry and a column for area name.
Use this table as the main data source (Location = geometry, Category/Legend = area name) so that slicers truly filter the underlying rows; the Azure Maps auto‑zoom then fits only the selected shapes, not the whole file.
2. Control zoom/center manually
Turn Auto zoom off in the Azure Maps visual and set a fixed zoom/center that works reasonably well for your typical areas.
Optionally, add helper measures or bookmarks that switch the map to predefined views (e.g. country, region) when users click buttons, but this still will not fully auto‑fit each polygon.
3. Consider alternative visuals
If you need precise “zoom to selected polygon” behaviour, a custom visual such as Icon Map or the Shape Map visual can load GeoJSON per region and auto‑zoom when filtered, which often behaves closer to what you want.
In short, the recommended approach is to load polygons as regular table data (data‑bound layer) instead of a single GeoJSON reference layer, so that cross‑filtering and auto‑zoom respect the user’s selection.