Op vrijdag 18 november 2016 11:22:51 UTC+1 schreef Tim Bezhashvyly: > > That's the issue. By the time load command is sent the HTML markup must be > already present at the page. >
I am not to familiar with Google maps integration, but it looks like the actual update of the map in the DOM is done in javascript, not in Elm. The value is sent to elm and stored in the model, but elm doesn't really do anything with this data. I suspect that the Time command won't work, because it is made immediately, and gives results immediately. It does not wait for DOM to be rendered. So probably javascript will give you a (not so helpful) error. If you want to make sure that something is in the DOM, you could look at http://package.elm-lang.org/packages/elm-lang/animation-frame/1.0.1/AnimationFrame. Which works with subscriptions. And feeds to your model only after every DOM update. This would require a bit more to setup. Something like: - add a variable like `mapState` in the model that has the map state, e.g. `type MapState = NoMapHere | Loading | Rendered` - in your init function, set the value to `mapState = Loading` - in your subscriptions, subscribe to `AnimationFrame.times` only if your mapState is `Loading`, and let it produce a `Tick` - in your update function, your `Tick` update should a) do `mapState = Rendered` (canceling your subscription) and b) send the loadMap command out With a button, it is easier: if you render the button together with your gmap, you can be sure that the load is only called if the gmap is rendered. The button can only be clicked if it is in the DOM, which means the map must also be in the DOM. -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
