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