Still doesn't even nearly work, but progress...
This commit is contained in:
parent
86c675f22d
commit
abb1c000ec
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -14,3 +14,7 @@ profiles.clj
|
|||
|
||||
/node_modules
|
||||
/log
|
||||
|
||||
.idea/
|
||||
|
||||
*.iml
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
[cljs-ajax "0.8.0"]
|
||||
[cljsjs/leaflet "1.2.0-0"]
|
||||
[clojure.java-time "0.3.2"]
|
||||
[com.cemerick/url "0.1.1"]
|
||||
[com.cognitect/transit-clj "0.8.319"]
|
||||
[cprop "0.1.15"]
|
||||
[day8.re-frame/http-fx "0.1.6"]
|
||||
|
|
34
resources/public/data/data.csv
Normal file
34
resources/public/data/data.csv
Normal file
|
@ -0,0 +1,34 @@
|
|||
Councils by Population Size,Name,Organisation ,Category,Population,,Latitude,Longitude,Co-ordinates
|
||||
1,Glasgow,Glasgow City Council,Planning authority,626,,55.86,-4.25,"55.86, -4.25"
|
||||
2,Edinburgh,City of Edinburgh Council ,Planning authority,518,,55.96,-3.18,"55.96, -3.18"
|
||||
3,Fife,Fife Council,Planning authority,372,,56.2,-3.16,"56.20, -3.16"
|
||||
4,North Lanarkshire,North Lanarkshire Council,Planning authority,340,,55.95,-3.99,"55.95, -3.99"
|
||||
5,South Lanarkshire,South Lanarkshire Council,Planning authority,319,,55.78,-4.05,"55.78, -4.05"
|
||||
6,Aberdeenshire,Aberdeenshire Council,Planning authority,261,,57.28,-2.37,"57.28, -2.37"
|
||||
7,Highland,Highland Council,Planning authority,235,,57.48,-4.22,"57.48, -4.22"
|
||||
8,Aberdeen,Aberdeen City Council.,Planning authority,228,,57.15,-2.09,"57.15, -2.09"
|
||||
9,West Lothian,West Lothian Council,Planning authority,182,,55.93,-3.46,"55.93, -3.46"
|
||||
10,Renfrewshire,Renfrewshire Council,Planning authority,178,3259,55.84,-4.42,"55.84, -4.42"
|
||||
11,Falkirk,Falkirk Council,Planning authority,160,,,,
|
||||
12,Perth and Kinross,Perth and Kinross Council,Planning authority,151,,,,
|
||||
13,Dumfries and Galloway,Dumfries and Galloway Council.,Planning authority,149,,,,
|
||||
14,Dundee,Dundee City Council.,Planning authority,149,,,,
|
||||
15,North Ayrshire,North Ayrshire Council,Planning authority,135,,,,
|
||||
16,East Ayrshire,East Ayrshire Council,Planning authority,122,,,,
|
||||
17,Angus,Angus Council.,Planning authority,116,,,,
|
||||
18,Scottish Borders,Scottish Borders Council,Planning authority,115,,,,
|
||||
19,South Ayrshire,South Ayrshire Council,Planning authority,113,,,,
|
||||
20,East Dunbartonshire,East Dunbartonshire Council,Planning authority,108,,,,
|
||||
21,East Lothian,East Lothian Council,Planning authority,106,,,,
|
||||
22,Moray,Moray Council,Planning authority,96,,,,
|
||||
23,East Renfrewshire,East Renfrewshire Council,Planning authority,95,,,,
|
||||
24,Stirling,Stirling Council,Planning authority,94,,,,
|
||||
25,Midlothian,Midlothian Council,Planning authority,91,,,,
|
||||
26,West Dunbartonshire,West Dunbartonshire Council,Planning authority,89,,,,
|
||||
27,Argyll and Bute,Argyll and Bute Council.,Planning authority,86,,,,
|
||||
28,Inverclyde,Inverclyde Council,Planning authority,78,,,,
|
||||
29,Clackmannanshire,Clackmannanshire Council.,Planning authority,51,,,,
|
||||
30,Na h-Eileanan Siar,Comhairle nan Eilean Siar (Western Isles) Council,Planning authority,26,,,,
|
||||
31,Shetland,Shetland Islands Council,Planning authority,23,,,,
|
||||
32,Orkney,Orkney Islands Council,Planning authority,22,,58.9,-2.9,"58.90, -2.90"
|
||||
,,,Total,5434,,,,
|
|
298
resources/public/data/data.edn
Normal file
298
resources/public/data/data.edn
Normal file
|
@ -0,0 +1,298 @@
|
|||
|
||||
({:councils-by-population-size 1,
|
||||
:name "Glasgow",
|
||||
:organisation- "Glasgow City Council",
|
||||
:category "Planning authority",
|
||||
:population 626,
|
||||
: "",
|
||||
:latitude 55.86,
|
||||
:longitude -4.25,
|
||||
:co-ordinates "55.86, -4.25"}
|
||||
{:councils-by-population-size 2,
|
||||
:name "Edinburgh",
|
||||
:organisation- "City of Edinburgh Council ",
|
||||
:category "Planning authority",
|
||||
:population 518,
|
||||
: "",
|
||||
:latitude 55.96,
|
||||
:longitude -3.18,
|
||||
:co-ordinates "55.96, -3.18"}
|
||||
{:councils-by-population-size 3,
|
||||
:name "Fife",
|
||||
:organisation- "Fife Council",
|
||||
:category "Planning authority",
|
||||
:population 372,
|
||||
: "",
|
||||
:latitude 56.2,
|
||||
:longitude -3.16,
|
||||
:co-ordinates "56.20, -3.16"}
|
||||
{:councils-by-population-size 4,
|
||||
:name "North Lanarkshire",
|
||||
:organisation- "North Lanarkshire Council",
|
||||
:category "Planning authority",
|
||||
:population 340,
|
||||
: "",
|
||||
:latitude 55.95,
|
||||
:longitude -3.99,
|
||||
:co-ordinates "55.95, -3.99"}
|
||||
{:councils-by-population-size 5,
|
||||
:name "South Lanarkshire",
|
||||
:organisation- "South Lanarkshire Council",
|
||||
:category "Planning authority",
|
||||
:population 319,
|
||||
: "",
|
||||
:latitude 55.78,
|
||||
:longitude -4.05,
|
||||
:co-ordinates "55.78, -4.05"}
|
||||
{:councils-by-population-size 6,
|
||||
:name "Aberdeenshire",
|
||||
:organisation- "Aberdeenshire Council",
|
||||
:category "Planning authority",
|
||||
:population 261,
|
||||
: "",
|
||||
:latitude 57.28,
|
||||
:longitude -2.37,
|
||||
:co-ordinates "57.28, -2.37"}
|
||||
{:councils-by-population-size 7,
|
||||
:name "Highland",
|
||||
:organisation- "Highland Council",
|
||||
:category "Planning authority",
|
||||
:population 235,
|
||||
: "",
|
||||
:latitude 57.48,
|
||||
:longitude -4.22,
|
||||
:co-ordinates "57.48, -4.22"}
|
||||
{:councils-by-population-size 8,
|
||||
:name "Aberdeen",
|
||||
:organisation- "Aberdeen City Council.",
|
||||
:category "Planning authority",
|
||||
:population 228,
|
||||
: "",
|
||||
:latitude 57.15,
|
||||
:longitude -2.09,
|
||||
:co-ordinates "57.15, -2.09"}
|
||||
{:councils-by-population-size 9,
|
||||
:name "West Lothian",
|
||||
:organisation- "West Lothian Council",
|
||||
:category "Planning authority",
|
||||
:population 182,
|
||||
: "",
|
||||
:latitude 55.93,
|
||||
:longitude -3.46,
|
||||
:co-ordinates "55.93, -3.46"}
|
||||
{:councils-by-population-size 10,
|
||||
:name "Renfrewshire",
|
||||
:organisation- "Renfrewshire Council",
|
||||
:category "Planning authority",
|
||||
:population 178,
|
||||
: 3259,
|
||||
:latitude 55.84,
|
||||
:longitude -4.42,
|
||||
:co-ordinates "55.84, -4.42"}
|
||||
{:councils-by-population-size 11,
|
||||
:name "Falkirk",
|
||||
:organisation- "Falkirk Council",
|
||||
:category "Planning authority",
|
||||
:population 160,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 12,
|
||||
:name "Perth and Kinross",
|
||||
:organisation- "Perth and Kinross Council",
|
||||
:category "Planning authority",
|
||||
:population 151,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 13,
|
||||
:name "Dumfries and Galloway",
|
||||
:organisation- "Dumfries and Galloway Council.",
|
||||
:category "Planning authority",
|
||||
:population 149,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 14,
|
||||
:name "Dundee",
|
||||
:organisation- "Dundee City Council.",
|
||||
:category "Planning authority",
|
||||
:population 149,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 15,
|
||||
:name "North Ayrshire",
|
||||
:organisation- "North Ayrshire Council",
|
||||
:category "Planning authority",
|
||||
:population 135,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 16,
|
||||
:name "East Ayrshire",
|
||||
:organisation- "East Ayrshire Council",
|
||||
:category "Planning authority",
|
||||
:population 122,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 17,
|
||||
:name "Angus",
|
||||
:organisation- "Angus Council.",
|
||||
:category "Planning authority",
|
||||
:population 116,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 18,
|
||||
:name "Scottish Borders",
|
||||
:organisation- "Scottish Borders Council",
|
||||
:category "Planning authority",
|
||||
:population 115,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 19,
|
||||
:name "South Ayrshire",
|
||||
:organisation- "South Ayrshire Council",
|
||||
:category "Planning authority",
|
||||
:population 113,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 20,
|
||||
:name "East Dunbartonshire",
|
||||
:organisation- "East Dunbartonshire Council",
|
||||
:category "Planning authority",
|
||||
:population 108,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 21,
|
||||
:name "East Lothian",
|
||||
:organisation- "East Lothian Council",
|
||||
:category "Planning authority",
|
||||
:population 106,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 22,
|
||||
:name "Moray",
|
||||
:organisation- "Moray Council",
|
||||
:category "Planning authority",
|
||||
:population 96,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 23,
|
||||
:name "East Renfrewshire",
|
||||
:organisation- "East Renfrewshire Council",
|
||||
:category "Planning authority",
|
||||
:population 95,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 24,
|
||||
:name "Stirling",
|
||||
:organisation- "Stirling Council",
|
||||
:category "Planning authority",
|
||||
:population 94,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 25,
|
||||
:name "Midlothian",
|
||||
:organisation- "Midlothian Council",
|
||||
:category "Planning authority",
|
||||
:population 91,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 26,
|
||||
:name "West Dunbartonshire",
|
||||
:organisation- "West Dunbartonshire Council",
|
||||
:category "Planning authority",
|
||||
:population 89,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 27,
|
||||
:name "Argyll and Bute",
|
||||
:organisation- "Argyll and Bute Council.",
|
||||
:category "Planning authority",
|
||||
:population 86,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 28,
|
||||
:name "Inverclyde",
|
||||
:organisation- "Inverclyde Council",
|
||||
:category "Planning authority",
|
||||
:population 78,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 29,
|
||||
:name "Clackmannanshire",
|
||||
:organisation- "Clackmannanshire Council.",
|
||||
:category "Planning authority",
|
||||
:population 51,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 30,
|
||||
:name "Na h-Eileanan Siar",
|
||||
:organisation- "Comhairle nan Eilean Siar (Western Isles) Council",
|
||||
:category "Planning authority",
|
||||
:population 26,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 31,
|
||||
:name "Shetland",
|
||||
:organisation- "Shetland Islands Council",
|
||||
:category "Planning authority",
|
||||
:population 23,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""}
|
||||
{:councils-by-population-size 32,
|
||||
:name "Orkney",
|
||||
:organisation- "Orkney Islands Council",
|
||||
:category "Planning authority",
|
||||
:population 22,
|
||||
: "",
|
||||
:latitude 58.9,
|
||||
:longitude -2.9,
|
||||
:co-ordinates "58.90, -2.90"}
|
||||
{:councils-by-population-size "",
|
||||
:name "",
|
||||
:organisation- "",
|
||||
:category "Total",
|
||||
:population 5434,
|
||||
: "",
|
||||
:latitude "",
|
||||
:longitude "",
|
||||
:co-ordinates ""})
|
2
resources/public/data/data.json
Normal file
2
resources/public/data/data.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -34,6 +34,7 @@
|
|||
{:class (when @expanded? :is-active)}
|
||||
[:div.navbar-start
|
||||
[nav-link "#/" "Home" :home]
|
||||
[nav-link "#/map" "Map" :map]
|
||||
[nav-link "#/about" "About" :about]]]]))
|
||||
|
||||
(defn about-page []
|
||||
|
@ -47,10 +48,12 @@
|
|||
|
||||
(defn map-page []
|
||||
"Return the content for the main map page. Map showing current location."
|
||||
(js/console.log "Attempting to switch to map: 1")
|
||||
(mv/panel))
|
||||
|
||||
(def pages
|
||||
{:home #'home-page
|
||||
:map #'map-page
|
||||
:about #'about-page})
|
||||
|
||||
(defn page []
|
||||
|
@ -66,10 +69,10 @@
|
|||
(reitit/router
|
||||
[["/" {:name :home
|
||||
:view #'home-page
|
||||
:controllers [{:start (fn [_] (rf/dispatch [:page/init-home]))}]}]
|
||||
["/map" {:name :home
|
||||
:controllers [{:start (fn [_] (rf/dispatch [:init-home]))}]}]
|
||||
["/map" {:name :map
|
||||
:view #'map-page
|
||||
:controllers [{:start (fn [_] (rf/dispatch [:page/init-map]))}]}]
|
||||
:controllers [{:start (fn [_] (rf/dispatch [:init-map]))}]}]
|
||||
["/about" {:name :about
|
||||
:view #'about-page}]]))
|
||||
|
||||
|
@ -86,6 +89,7 @@
|
|||
(r/render [#'page] (.getElementById js/document "app")))
|
||||
|
||||
(defn init! []
|
||||
(rf/dispatch-sync [:initialise-db])
|
||||
(start-router!)
|
||||
(ajax/load-interceptors!)
|
||||
(mount-components))
|
||||
|
|
8
src/cljs/geocsv/db.cljs
Normal file
8
src/cljs/geocsv/db.cljs
Normal file
|
@ -0,0 +1,8 @@
|
|||
(ns ^{:doc "geocsv app initial database."
|
||||
:author "Simon Brooke"}
|
||||
geocsv.db)
|
||||
|
||||
(def default-db
|
||||
{:page :home
|
||||
:map {:map-centre [56 -4]
|
||||
:map-zoom 6}})
|
|
@ -1,65 +1,39 @@
|
|||
(ns geocsv.events
|
||||
(:require
|
||||
(:require [ajax.core :as ajax]
|
||||
[ajax.json :refer [json-request-format json-response-format]]
|
||||
[cemerick.url :refer [url url-encode]]
|
||||
[geocsv.db :refer [default-db]]
|
||||
[geocsv.gis :refer [refresh-map-pins]]
|
||||
[re-frame.core :as rf]
|
||||
[ajax.core :as ajax]
|
||||
[reitit.frontend.easy :as rfe]
|
||||
[reitit.frontend.controllers :as rfc]))
|
||||
|
||||
;;dispatchers
|
||||
|
||||
(rf/reg-event-db
|
||||
:navigate
|
||||
(fn [db [_ match]]
|
||||
(let [old-match (:common/route db)
|
||||
new-match (assoc match :controllers
|
||||
(rfc/apply-controllers (:controllers old-match) match))]
|
||||
(assoc db :route new-match))))
|
||||
(def source-host
|
||||
"The base URL of the host from which the app was loaded."
|
||||
(assoc
|
||||
(url js/window.location)
|
||||
:path "/"
|
||||
:query nil
|
||||
:anchor nil))
|
||||
|
||||
(rf/reg-fx
|
||||
:navigate-fx!
|
||||
(fn [[k & [params query]]]
|
||||
(rfe/push-state k params query)))
|
||||
|
||||
;;dispatchers: keep in alphabetical order, please.
|
||||
(rf/reg-event-fx
|
||||
:navigate!
|
||||
(fn [_ [_ url-key params query]]
|
||||
{:navigate-fx! [url-key params query]}))
|
||||
|
||||
(rf/reg-event-db
|
||||
:set-docs
|
||||
(fn [db [_ docs]]
|
||||
(assoc db :docs docs)))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:fetch-docs
|
||||
(fn [_ _]
|
||||
{:http-xhrio {:method :get
|
||||
:uri "/docs"
|
||||
:response-format (ajax/raw-response-format)
|
||||
:on-success [:set-docs]}}))
|
||||
:bad-data
|
||||
;; TODO: why is this an `-fx`? Does it need to be?
|
||||
(fn
|
||||
[{db :db} [_ response]]
|
||||
;; TODO: signal something has failed? It doesn't matter very much, unless it keeps failing.
|
||||
(js/console.log (str "Failed to fetch data data" response))
|
||||
db))
|
||||
|
||||
(rf/reg-event-db
|
||||
:common/set-error
|
||||
(fn [db [_ error]]
|
||||
(assoc db :common/error error)))
|
||||
|
||||
(reg-event-db
|
||||
:set-view
|
||||
(fn [db [_ view]]
|
||||
(assoc db :view view)))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:page/init-home
|
||||
(fn [_ _]
|
||||
{:dispatch [:fetch-docs]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:page/init-maps
|
||||
(fn [_ _]
|
||||
{:dispatch [:fetch-data]}))
|
||||
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
:fetch-data
|
||||
(fn [{db :db} _]
|
||||
(let [uri (assoc source-host
|
||||
|
@ -76,38 +50,106 @@
|
|||
:on-failure [:bad-data]}
|
||||
:db db})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
(rf/reg-event-fx
|
||||
:fetch-docs
|
||||
(fn [_ _]
|
||||
{:http-xhrio {:method :get
|
||||
:uri "/docs"
|
||||
:response-format (ajax/raw-response-format)
|
||||
:on-success [:set-docs]}}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:init-home
|
||||
(fn [_ _]
|
||||
{:dispatch [:fetch-docs]}))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:init-map
|
||||
(fn [_ _]
|
||||
{:dispatch [:fetch-data]}))
|
||||
|
||||
(rf/reg-event-db
|
||||
:initialise-db
|
||||
(fn [_ _]
|
||||
(js/console.log "Initialising state.")
|
||||
default-db))
|
||||
|
||||
(rf/reg-event-db
|
||||
:navigate
|
||||
(fn [db [_ match]]
|
||||
(let [old-match (:common/route db)
|
||||
new-match (assoc match :controllers
|
||||
(rfc/apply-controllers (:controllers old-match) match))]
|
||||
(assoc db :route new-match))))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:navigate!
|
||||
(fn [_ [_ url-key params query]]
|
||||
{:navigate-fx! [url-key params query]}))
|
||||
|
||||
(rf/reg-fx
|
||||
:navigate-fx!
|
||||
(fn [[k & [params query]]]
|
||||
(rfe/push-state k params query)))
|
||||
|
||||
(rf/reg-event-fx
|
||||
:process-data
|
||||
;; TODO: why is this an `-fx`? Does it need to be?
|
||||
(fn
|
||||
[{db :db} [_ response]]
|
||||
(let [data (js->clj response)]
|
||||
(js/console.log (str ":process-data: " response))
|
||||
{:db (refresh-map-pins (assoc db :data data))})))
|
||||
(js/console.log (str "processing fetched JSON data"))
|
||||
{:db (if
|
||||
(:view db)
|
||||
(refresh-map-pins (assoc db :data data))
|
||||
db)})))
|
||||
|
||||
(re-frame/reg-event-fx
|
||||
:bad-data
|
||||
;; TODO: why is this an `-fx`? Does it need to be?
|
||||
(fn
|
||||
[{db :db} [_ response]]
|
||||
;; TODO: signal something has failed? It doesn't matter very much, unless it keeps failing.
|
||||
(js/console.log (str "Failed to fetch data data" response))
|
||||
db))
|
||||
(rf/reg-event-db
|
||||
:set-docs
|
||||
(fn [db [_ docs]]
|
||||
(assoc db :docs docs)))
|
||||
|
||||
(rf/reg-event-db
|
||||
:set-view
|
||||
(fn [db [_ view]]
|
||||
(assoc db :view view)))
|
||||
|
||||
;;subscriptions
|
||||
;;subscriptions. Keep in alphabetical order, please
|
||||
|
||||
(rf/reg-sub
|
||||
:common/error
|
||||
(fn [db _]
|
||||
(:common/error db)))
|
||||
|
||||
(rf/reg-sub
|
||||
:docs
|
||||
(fn [db _]
|
||||
(:docs db)))
|
||||
|
||||
(rf/reg-sub
|
||||
:latitude
|
||||
(fn [db _]
|
||||
(let [v (or (first (:map-centre (:map db))) 54)]
|
||||
(js/console.log (str "Fetching latitude" v))
|
||||
v)))
|
||||
|
||||
(rf/reg-sub
|
||||
:longitude
|
||||
(fn [db _]
|
||||
(let [v (or (nth (:map-centre (:map db)) 1) -4)]
|
||||
(js/console.log (str "Fetching longitude" v))
|
||||
v)))
|
||||
|
||||
(rf/reg-sub
|
||||
:map
|
||||
(fn [db _]
|
||||
(:map db)))
|
||||
|
||||
(rf/reg-sub
|
||||
:route
|
||||
(fn [db _]
|
||||
(-> db :route)))
|
||||
|
||||
(rf/reg-sub
|
||||
:page-id
|
||||
:<- [:route]
|
||||
(fn [route _]
|
||||
(-> route :data :name)))
|
||||
|
||||
(rf/reg-sub
|
||||
:page
|
||||
:<- [:route]
|
||||
|
@ -115,11 +157,13 @@
|
|||
(-> route :data :view)))
|
||||
|
||||
(rf/reg-sub
|
||||
:docs
|
||||
(fn [db _]
|
||||
(:docs db)))
|
||||
:page-id
|
||||
:<- [:route]
|
||||
(fn [route _]
|
||||
(-> route :data :name)))
|
||||
|
||||
(rf/reg-sub
|
||||
:common/error
|
||||
:zoom
|
||||
(fn [db _]
|
||||
(:common/error db)))
|
||||
(:map-zoom (:map db))))
|
||||
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
(ns ^{:doc "geocsv app map stuff."
|
||||
:author "Simon Brooke"}
|
||||
geocsv.gis
|
||||
(:require [cljs.reader :refer [read-string]]
|
||||
(:require [ajax.core :refer [GET]]
|
||||
[ajax.json :refer [json-request-format json-response-format]]
|
||||
[cljs.reader :refer [read-string]]
|
||||
[clojure.string :refer [capitalize lower-case]]
|
||||
[cemerick.url :refer (url url-encode)]
|
||||
[day8.re-frame.http-fx]
|
||||
[re-frame.core :refer [dispatch reg-event-db reg-event-fx subscribe]]
|
||||
[ajax.core :refer [GET]]
|
||||
[ajax.json :refer [json-request-format json-response-format]]
|
||||
[youyesyet.locality :refer [locality]]
|
||||
))
|
||||
[re-frame.core :refer [dispatch reg-event-db reg-event-fx subscribe]]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;;
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
(defn map-did-mount-mapbox
|
||||
"Did-mount function loading map tile data from MapBox (proprietary)."
|
||||
[]
|
||||
(get-current-location)
|
||||
(let [view (.setView
|
||||
(.map js/L "map" (clj->js {:zoomControl "false"})))]
|
||||
;; NEED TO REPLACE FIXME with your mapID!
|
||||
|
@ -59,12 +58,12 @@
|
|||
(defn map-did-mount-osm
|
||||
"Did-mount function loading map tile data from Open Street Map."
|
||||
[]
|
||||
(get-current-location) ;; - [Violation] Only request geolocation information in response to a user gesture.
|
||||
(let [view (.setView
|
||||
(.map js/L
|
||||
"map"
|
||||
(clj->js {:zoomControl false}))
|
||||
#js [@(subscribe [:latitude]) @(subscribe [:longitude])]
|
||||
;; (clj->js {:zoomControl false})
|
||||
)
|
||||
#js [56 -4] ;;[@(subscribe [:latitude]) @(subscribe [:longitude])]
|
||||
@(subscribe [:zoom]))]
|
||||
(.addTo (.tileLayer js/L osm-url
|
||||
(clj->js {:attribution osm-attrib
|
||||
|
@ -76,8 +75,8 @@
|
|||
(js/console.log (str "Moving centre to " c))
|
||||
(dispatch-sync [:set-latitude (.-lat c)])
|
||||
(dispatch-sync [:set-longitude (.-lng c)])
|
||||
(dispatch [:fetch-locality]))))
|
||||
(refresh-map-pins)
|
||||
(dispatch [:fetch-data]))))
|
||||
;; (refresh-map-pins)
|
||||
view))
|
||||
|
||||
(defn map-did-mount
|
||||
|
@ -98,5 +97,6 @@
|
|||
"A reagent class for the map object."
|
||||
[]
|
||||
;; (get-current-location)
|
||||
(js/console.log "Attempting to switch to map: 2")
|
||||
(reagent/create-class {:reagent-render map-render
|
||||
:component-did-mount map-did-mount}))
|
||||
|
|
Loading…
Reference in a new issue