Script to reload map on resize event

Hi,


I'm looking to create a script to insert into the "Resize" property of a dashboard. What I want to do is reload the map I created after a resize of the browser has occured.


Here's the script I came up with

map3.metricSetBindings.forEach(function(metricSetBinding){ metricSetBinding.dataResult = null });

map3.loadData();


The problem is that the map sometimes reloads but sometimes doesn't, but when it does it's only reloading part of the map. I have the map in a section of a template grid too to make it response.


Any help would be appreciated.


Thanks!

Hi Daniel,

In order to understand the requirement a bit better, can you clarify and provide more details why reloading map data is needed when the browser is resized?


Regards

Hi Jay,


We were testing responsiveness of the embedded map and noticed that everytime we re-sized the browser the map would not re-size itself automatically and center. I tried the script above and it didn't work either. The ony way for it to look normal again after a browser re-size is if we actually hit refresh on the browser.


Let me know if you need more details.


Thanks!

Oh I have had this same issue, I just decided not to use responsive sizing.



Hi James,


What did you use instead? Did it resolve the issue?


Thanks!

It looks like the map is reloading when the page is resized and the dashboard is set to be responsive but the reloading isn't centering the map as expected. I've submitted a request to have that checked. In the meantime, you can add the following 1 line script to your dashboard resize action:


window.location.reload();


This will force the page to reload on resize and should have your map centered as expected.

I did nothing, I do not have many users in the need of the resize feature so I stoped looking into it.


Thanks Ariel for having this issue looked into.

Quick update in case someone run into this one - maps will reload when using responsive mode and re-center accordingly (no scripting required). It may not show exactly the same thing as it can’t if the new page size aspect ratio changes, but it maintains the same center point and zoom level and expands to fill the template cell as it changes size.
Let us know if you see a different behavior.