2D/3D Toggle Event
TerminéeRELEASED: Web 5.25
Should the map initialize event fire when a user swaps to a 2D/3D map with the toggle map component?
-
Commentaire officiel
Andrew Adamson I think you'll find the event fires when Web loads the map object configuration and initializes it. It doesn't matter if that has a single 2D map, a single 3D scene, or both.
The 3D scene is initialized and loaded slowly in the background so that the 2D / 3D toggle for an end user appears to be virtually instant (assuming you've been interacting with the app for a minute or so).
For example, if you were running a multi-layout app with different maps, the map in an alternate layout likely won't initialize until the first time it is made visible.
There are lower level events you can look at related to when views are activated that may serve your purposes if you are trying to setup something that is along the lines of 'now that this is visible to the end user I want to do this task'.
-
Thanks for the tips. I'll add a service to my app and subscribe to a few events to see if they trigger on the map 2D/3D toggle.
Little more context. Would like to add 3D to our public facing web app. Have a 2D web map and 3D web map configured under the same map component. Both with the same layers/groups - in the scene I have an additional group called 3D where I'm storing our county wide integrated mesh.
I've noticed the network calls the scene will make in the background while the 2D map is activated. Its doing this to make a toggle seamless as possible but in practice its detrimental. I can go into more detail but overall this is excessive when dealing with our county wide mesh layer, Imagery, DEM, etc. So my thinking is, hey leave these layers off when it loads the scene - this will negate the scene network calls under the hood. When the user switches to 3D, turn said layers on, when user switched back to 2D, turn said layers off.
Would any of the ui events trigger on a map toggle?0 -
Nothing I can find for an event.
There are a couple other approaches you can consider.
If it is a relatively low % of your users who will look at the 3D view, you might want to add two map components with a dedicated 2D map there and visible by default and a second hidden 3D map that is only loaded if someone actually wants to see it. You lose the integrated little 2D/3D toggle, but you gain not loading that 3D scene unless someone actually says they want to see it. You can build your own little toggle using a button with two states. In addition to the show/hide commands you'd use here for the map component you could also create a dedicated 3D layout and then use standard layout switching events and commands to switch between the two layouts.
0 -
Swapping layouts can get me close but I run into issue when dealing with custom components and adds some maintenance. Using the toggle 2D/3D switcher plays nice with custom components when a maker is on the map, remembering the location, and if any workflows are open at the time. I think I found a way to get into the toggle event though with a custom service.
1) Subscribe to the map.initialized event
2) Inside, add a map.watch() on the viewMode property.
3) Do stuff when viewMode changes to scene.
Would be cool if we could subscribe to a this.messages.events.map.toggled event. Little use case but seems the viewer is tracking the event already:
0 -
Hi Andrew - yes, longer term we should be exposing an event for you. Short term, you are correct that it is observable.
MapModel.watch("isSwitchingViewMode", (newValue, oldValue) => {// doSomething;})0
Vous devez vous connecter pour laisser un commentaire.
Commentaires
5 commentaires