From 8aac10c699f0c678f62bffc9bb3457618bc1c62f Mon Sep 17 00:00:00 2001 From: andre-dietrich Date: Fri, 9 Aug 2019 14:38:04 +0200 Subject: fixing error "style is not done loading" a little modification according to the following suggestion : https://bl.ocks.org/malwoodsantoro/43bba1d03a8d22c10b3e9943eb0c55d1 --- src/js/main.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/js/main.js b/src/js/main.js index e5112fb..61054cc 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -255,12 +255,16 @@ export function registerCustomElement(settings) { this._eventRegistrationQueue = {}; options.onMount(this._map, this); if (commandRegistry[this.id]) { - this._map.on("load", () => { - var cmd; - while ((cmd = commandRegistry[this.id].shift())) { - cmd(this._map); - } - }); + function onStyleData(){ + if(map.isStyleLoaded()) { + var cmd; + while ((cmd = commandRegistry[this.id].shift())) { + cmd(this._map); + } + map.off('data', onStyleData) + } + }; + this._map.on("data", onStyleData); } return this._map; } -- cgit v1.2.3 From 0a083bffd310976338fe7015c648837718260c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Dietrich?= Date: Fri, 6 Sep 2019 13:33:31 +0200 Subject: added zoom_ and center_ attributes to mapbox Elements --- src/Mapbox/Element.elm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Mapbox/Element.elm b/src/Mapbox/Element.elm index 7802983..5a93501 100644 --- a/src/Mapbox/Element.elm +++ b/src/Mapbox/Element.elm @@ -1,6 +1,6 @@ module Mapbox.Element exposing ( map, css, MapboxAttr - , token, id, maxZoom, minZoom, maxBounds, renderWorldCopies, featureState + , token, id, zoom_, center_, maxZoom, minZoom, maxBounds, renderWorldCopies, featureState , EventData, TouchEvent, eventFeaturesFilter, eventFeaturesLayers , onMouseDown, onMouseUp, onMouseOver, onMouseMove, onClick, onDblClick, onMouseOut, onContextMenu, onZoom, onZoomStart, onZoomEnd, onRotate, onRotateStart, onRotateEnd, onTouchEnd, onTouchMove, onTouchCancel, on ) @@ -12,7 +12,7 @@ module Mapbox.Element exposing ### Attributes -@docs token, id, maxZoom, minZoom, maxBounds, renderWorldCopies, featureState +@docs token, id, zoom_, center_, maxZoom, minZoom, maxBounds, renderWorldCopies, featureState ### Events @@ -75,6 +75,20 @@ css = node "link" [ attribute "href" "https://api.tiles.mapbox.com/mapbox-gl-js/v0.53.0/mapbox-gl.css", attribute "rel" "stylesheet" ] [] +{-| Define the default zoom level of the map (0-24). +-} +zoom_ : Float -> MapboxAttr msg +zoom_ = + Encode.float >> property "zoom" >> MapboxAttr + + +{-| The default center pos. +-} +center_ : LngLat -> MapboxAttr msg +center_ = + LngLat.encodeAsPair >> property "center" >> MapboxAttr + + {-| The minimum zoom level of the map (0-24). -} minZoom : Float -> MapboxAttr msg -- cgit v1.2.3