I have a custom Mapbox map built in the page with the help of “Web browser”. It is a simple vanilla js map with a global variable MAP. I want to access this variable with buttons. So for example on button click call "MAP.setCenter() " etc.
Unfortunately, it’s not possible to inject javascript function to inner content of a Web Browser Asset.
However, instead of using a Web Browser Asset, I recommend you to use a Map Collection Asset. It’s based on Mapbox too and comes with a set of actions for you to manipulate it directly from your experience.
but is it possible to somehow change the URL in ‘web browser’ component but do not reload the page.
like window.history.pushState('page2', 'Title', '/page2.php');
You can change the URL or a Web Browser using actions provided with the asset itself.
In that case, use the Open URL one.
Needs to be tested but to be honest, I always try to use as less code as possible. Especially when there is already a Collection (in that case, Map) built-in, that fulfill my needs with its actions (in that case, Set viewport).
we have a complex mapbox map with custom API calls, filters etc. there is no way to use the ‘Map Collection’ as it functionality is insufficient.
As I understand Open URL will reload the page with the new address.
So maybe there are any hacks to access global variables? or somehow communicate with the web browser component?