Still not working
This commit is contained in:
parent
2594a1954f
commit
db5a034d9a
|
@ -45,6 +45,7 @@
|
|||
[re-frame "0.10.9"]
|
||||
[reagent "0.8.1"]
|
||||
[reagent-utils "0.3.3"]
|
||||
[recalcitrant "0.1.2"]
|
||||
[ring-middleware-format "0.7.4"]
|
||||
[ring/ring-defaults "0.3.2"]
|
||||
[ring/ring-servlet "1.7.1"]
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
[reagent.core :as r]
|
||||
[re-frame.core :as rf]
|
||||
[re-frame.fx]
|
||||
[recalcitrant.core :refer [error-boundary]] ;; may not be needed here
|
||||
[secretary.core :as secretary]
|
||||
[youyesyet.canvasser-app.ajax :refer [load-interceptors!]]
|
||||
[youyesyet.canvasser-app.gis :refer [get-current-location]]
|
||||
|
@ -118,7 +119,7 @@
|
|||
[:div
|
||||
[:header
|
||||
[ui/navbar]]
|
||||
(if content [content]
|
||||
(if content [error-boundary [content]]
|
||||
[:div.error (str "No content in page " @(rf/subscribe [:page]))])
|
||||
[:footer
|
||||
[:div.error {:style [:display (if (empty? error) :none :block)]} (apply str error)]
|
||||
|
|
|
@ -45,13 +45,23 @@
|
|||
(.getCurrentPosition
|
||||
(.-geolocation js/navigator)
|
||||
(fn [position]
|
||||
(let [lat (.-latitude (.-coords position))
|
||||
(let [view @(subscribe [:view])
|
||||
lat (.-latitude (.-coords position))
|
||||
lng (.-longitude (.-coords position))]
|
||||
(js/console.log (str "Current location is: " lat ", " lng))
|
||||
(dispatch [:set-latitude lat])
|
||||
(dispatch [:set-longitude lng])
|
||||
(.panTo @(subscribe [:view]) (.latLng js/L lat lng))
|
||||
(locality lat lng))))
|
||||
(if
|
||||
(and view (float? lat) (float? lng))
|
||||
(do
|
||||
(dispatch [:set-latitude lat])
|
||||
(dispatch [:set-longitude lng])
|
||||
(.panTo view (.latLng js/L lat lng))
|
||||
(locality lat lng))
|
||||
(do
|
||||
(js/console.log
|
||||
(if view
|
||||
(str "Geolocation failed lat: '" lat "'; lng '" lng "'")
|
||||
"No value for subscription to [:view]"))
|
||||
0)))))
|
||||
(do
|
||||
(js/console.log "Geolocation not available")
|
||||
0))
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
(:require [cljsjs.leaflet]
|
||||
[re-frame.core :refer [reg-sub subscribe dispatch dispatch-sync]]
|
||||
[reagent.core :as reagent]
|
||||
[recalcitrant.core :refer [error-boundary]]
|
||||
[youyesyet.canvasser-app.gis :refer [refresh-map-pins get-current-location]]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
@ -49,7 +50,7 @@
|
|||
;;; thought.
|
||||
|
||||
;; which provider to use
|
||||
(def ^dynamic *map-provider* :osm)
|
||||
(def ^:dynamic *map-provider* :osm)
|
||||
|
||||
(def osm-url "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")
|
||||
(def osm-attrib "Map data © <a href='http://openstreetmap.org'>OpenStreetMap</a> contributors")
|
||||
|
@ -71,7 +72,7 @@
|
|||
(defn map-did-mount-osm
|
||||
"Did-mount function loading map tile data from Open Street Map."
|
||||
[]
|
||||
(get-current-location)
|
||||
(get-current-location) ;; - [Violation] Only request geolocation information in response to a user gesture.
|
||||
(let [view (.setView
|
||||
(.map js/L
|
||||
"map"
|
||||
|
@ -112,6 +113,6 @@
|
|||
(defn panel
|
||||
"A reagent class for the map object."
|
||||
[]
|
||||
(get-current-location)
|
||||
;; (get-current-location)
|
||||
(reagent/create-class {:reagent-render map-render
|
||||
:component-did-mount map-did-mount}))
|
||||
|
|
Loading…
Reference in a new issue