Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Commit

Permalink
refactor: cleanup a bit
Browse files Browse the repository at this point in the history
- Map over props
- Extract access-token
- Use Google Closure methods

Note: bearing and pitch are not possible in Leaflet
See mapbox/mapbox-gl-leaflet#43
Same for rotation.
See Leaflet/Leaflet#268
  • Loading branch information
Erwin Rooijakkers committed Jul 17, 2018
1 parent 4b5bc1e commit b4d00a2
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions iota.alliander.com/src/cljs/decentralized_auth/views.cljs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
(ns decentralized-auth.views
(:require cljsjs.noty
[decentralized-auth.utils :refer [debug-panel json-encode]]
[goog.object :as object]
[goog.string :as string]
[re-frame.core :refer [dispatch subscribe]]
[reagent.core :as r]))

Expand All @@ -15,27 +17,27 @@
:layout "bottomRight"
:timeout 10000})))

;; :bearing 64
;; :pitch 42

(defn map-view-render []
[:div#map])


(defn map-view-did-mount []
;; (set! (.-accessToken js/mapboxgl)
;; "pk.eyJ1IjoiZXJ3aW5hbGxpYW5kZXIiLCJhIjoiY2pqaWRwdmFpNWNmcjNyczJ0aDJpZzE0byJ9.AIp1C3D3wCjbPvfpOShydg")
(let [mapbox (.setView (.map js/L "map") #js [53.38723233031408 5.788068297037057] 11)]
;; (.disable (.-scrollZoom mapbox))
;; (.disable (.-keyboard mapbox))
;; (.disable (.-doubleClickZoom mapbox))
;; (.addControl mapbox (new (.-NavigationControl js/mapboxgl)) "top-left")
(def access-token
(string/buildString
"pk.eyJ1IjoiZXJ3aW5hbGxpYW5kZXIiLCJhIjoiY2pqaWRwdmF"
"pNWNmcjNyczJ0aDJpZzE0byJ9.AIp1C3D3wCjbPvfpOShydg"))


(.addTo (.tileLayer js/L "https://api.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}"
(defn map-view-did-mount []
(let [mapbox (.setView (.map js/L "map") #js [53.418 5.776] 13)]
(set! js/foo mapbox)
(doseq [prop #{"scrollWheelZoom" "doubleClickZoom" "keyboard"}]
(.disable (object/get mapbox prop)))
(.addTo (.tileLayer js/L
"https://api.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}"
(clj->js {:attribution "Map data © [...]"
:maxZoom 18
:id "mapbox.streets"
:accessToken "pk.eyJ1IjoiZXJ3aW5hbGxpYW5kZXIiLCJhIjoiY2pqaWRwdmFpNWNmcjNyczJ0aDJpZzE0byJ9.AIp1C3D3wCjbPvfpOShydg"}))
:accessToken access-token}))
mapbox

;; (let [marker (new (.-Marker js/mapboxgl) #js {:color "red" :label "pin-l-water"})]
Expand Down

0 comments on commit b4d00a2

Please sign in to comment.