Forum Discussion
Azure Maps – Dynamic zoom when filtering polygons from a single GeoJSON?
Hi everyone,
I am using Azure Maps in Power BI, and I have multiple areas/polygons stored inside one single GeoJSON file. I want to allow the user to filter the report (for example using a slicer), so that only one area is displayed at a time.
The problem I’m facing is that Azure Maps still reads the full extent of the entire GeoJSON file, even when the data is filtered. So the map automatically zooms out to show all the shapes, which makes the visible area look extremely far away. In practice, the filtering hides the data, but not the underlying geometry that the zoom is calculated from.
My questions are:
Is there any workaround so that Azure Maps can zoom only to the selected area when using a single GeoJSON file?
Is it possible to define_zoom or center position dynamically based on the user selection?
If not, what would be the recommended approach?
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 🌀.
5 Replies
- ZanquetaSuper User
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 🌀. - v-sshirivoluCommunity Support
Hi Anonymous ,
I would also take a moment to thank Zanqueta , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions
- v-sshirivoluCommunity Support
Hi Anonymous ,
I hope the information provided above assists you in resolving the issue. If you have any additional questions or concerns, please do not hesitate to contact us. We are here to support you and will be happy to help with any further assistance you may need.
- Nabha-AhmedSuper User
Hi Anonymous
This happens because Azure Maps calculates zoom/extent based on the full GeoJSON geometry, even if you filter features. Filtering only hides the data; it doesn’t change the underlying geometry.
Workarounds:
- the GeoJSON by area – have one file per area, then use a slicer to dynamically load the selected file. This ensures correct zoom.
- Use pre-calculated centroids – create a table with each area’s center coordinates and zoom level, and bind the map to these measures. Works best for highlighting, less so for full polygons.
Recommendation: Splitting the GeoJSON per area is usually the simplest way to get proper zoom for each selection.
i hope this help you
- Shubham_rai955Super User
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.