diff --git a/resources/public/css/style.css b/resources/public/css/style.css index 4117c97..de8c37f 100644 --- a/resources/public/css/style.css +++ b/resources/public/css/style.css @@ -35,7 +35,7 @@ footer a { h1, h2, h3, h4, h5, h6 { width: 100%; margin: 0; - padding-left: 10%; + padding: 0.5em 10%; text-align: left; background-color: #3298dc; color: white; @@ -44,3 +44,19 @@ h1, h2, h3, h4, h5, h6 { samp { background-color: #b0b0ff; } + +#error +{ + background-color: maroon; + color: white; + margin: 0px; + padding-left: 10%; +} + +#message +{ + background-color: darkgreen; + color: white; + margin: 0px; + padding-left: 10%; +} diff --git a/resources/public/index.html b/resources/public/index.html index 8b1c5dd..d70e493 100644 --- a/resources/public/index.html +++ b/resources/public/index.html @@ -18,9 +18,9 @@ crossorigin=""/ -->
diff --git a/src/geocsv_lite/core.cljs b/src/geocsv_lite/core.cljs index f9bea4c..b6b7197 100644 --- a/src/geocsv_lite/core.cljs +++ b/src/geocsv_lite/core.cljs @@ -4,14 +4,15 @@ [clojure.string :as cs] [geocsv-lite.data :refer [get-csv-url get-data get-query-part-as-map]] [geocsv-lite.gis :as gis] - [geocsv-lite.map :as m])) + [geocsv-lite.map :as m] + [geocsv-lite.notify :as n])) (defn ^:export initialise-map-element "Create a map view in the element with this `id` and decorate it with pins showing locations from this `data-source`." [id data-source] - (js/console.log (str "geocsv-lite.core.initialise-map-element called with args id: " id "; data-source: " data-source ".")) + (n/message (str "geocsv-lite.core.initialise-map-element called with args id: " id "; data-source: " data-source ".")) (let [sid (str id) kid (keyword sid) v (m/add-view sid 55 -4 10)] diff --git a/src/geocsv_lite/data.cljs b/src/geocsv_lite/data.cljs index 0a47210..c768db1 100644 --- a/src/geocsv_lite/data.cljs +++ b/src/geocsv_lite/data.cljs @@ -6,8 +6,7 @@ [cljs.core.async :refer [js [(:latitude centre) (:longitude centre)]) (:zoom centre))))) - (do (js/console.log "View is not yet ready"))))) + (.setView view (clj->js [(:latitude centre) (:longitude centre)]) (:zoom centre)))) + (do (n/error "View is not yet ready"))))) diff --git a/src/geocsv_lite/map.cljs b/src/geocsv_lite/map.cljs index f56698c..3700a85 100644 --- a/src/geocsv_lite/map.cljs +++ b/src/geocsv_lite/map.cljs @@ -1,5 +1,5 @@ (ns geocsv-lite.map - (:require )) + (:require [geocsv-lite.notify :as n])) ;;; Cribbed heavily from ;;; https://github.com/reagent-project/reagent-cookbook/tree/master/recipes/leaflet @@ -76,15 +76,15 @@ v (or (@views k) (map-did-mount id lat lng zoom))] - (js/console.log (str "Added Leaflet view to element with id `" id "`")) + (n/message (str "Added Leaflet view to element with id `" id "`")) (swap! views assoc k v) v)) (defn get-view [k] - (when-not (keyword? k) (js/console.log "Key `" k "` passed to get-view is not a keyword")) - (when-not (k @views) (js/console.log "Key `" k "` does not identify a known view")) + (when-not (keyword? k) (n/message (str "Key `" k "` passed to get-view is not a keyword"))) + (when-not (k @views) (n/message (str "Key `" k "` does not identify a known view"))) (k @views)) diff --git a/src/geocsv_lite/notify.cljs b/src/geocsv_lite/notify.cljs new file mode 100644 index 0000000..63b2f8a --- /dev/null +++ b/src/geocsv_lite/notify.cljs @@ -0,0 +1,13 @@ +(ns geocsv-lite.notify + (:require [clojure.browser.dom :as dom])) + +(defn message + [msg] + (js/console.log msg) + (dom/set-text (.getElementById js/document "message") msg)) + + +(defn error + [err] + (js/console.error err) + (dom/set-text (.getElementById js/document "error") err))