Map pins on map working!
This commit is contained in:
parent
b95fa9919e
commit
6c50592543
|
@ -62,23 +62,27 @@
|
|||
"Add a map-pin with this pin-image at this latitude and longitude
|
||||
in this map view"
|
||||
[latitude longitude pin-image view]
|
||||
(let [pin
|
||||
(.Icon js/L
|
||||
{:iconUrl (str "img/map-pins/" pin-image ".png")
|
||||
:shadorUrl "img/map-pins/shadow_pin.png"
|
||||
:iconSize [32 42]
|
||||
:shadowSize [57 24]
|
||||
:iconAnchor [16 41]
|
||||
:shadowAnchor [16 23]}
|
||||
)]
|
||||
(.addTp (.marker js/L [latitude longitude] {:icon pin})) view))
|
||||
(js/console.log (str "Adding pin " pin-image " at " latitude "," longitude))
|
||||
(let [pin (.icon js/L
|
||||
(clj->js
|
||||
{:iconUrl (str "img/map-pins/" pin-image ".png")
|
||||
:shadowUrl "img/map-pins/shadow_pin.png"
|
||||
:iconSize [32 42]
|
||||
:shadowSize [57 24]
|
||||
:iconAnchor [16 41]
|
||||
:shadowAnchor [16 23]}))
|
||||
marker (.marker js/L
|
||||
(.latLng js/L 55.82 -4.25)
|
||||
(clj->js {:icon pin}))
|
||||
]
|
||||
(.addTo marker view)))
|
||||
|
||||
|
||||
;; My gods mapbox is user-hostile!
|
||||
(defn map-did-mount-mapbox
|
||||
"Did-mount function loading map tile data from MapBox (proprietary)."
|
||||
[]
|
||||
(let [view (.setView (.map js/L "map") #js [55.82 -4.25] 13)]
|
||||
(let [view (.setView (.map js/L "map" (clj->js {:zoomControl "false"})) #js [55.82 -4.25] 13)]
|
||||
;; NEED TO REPLACE FIXME with your mapID!
|
||||
(.addTo (.tileLayer js/L "http://{s}.tiles.mapbox.com/v3/FIXME/{z}/{x}/{y}.png"
|
||||
(clj->js {:attribution "Map data © [...]"
|
||||
|
@ -87,15 +91,16 @@
|
|||
|
||||
|
||||
(defn map-did-mount-osm
|
||||
"Did-mount function loading map tile data from Open Street Map (open)."
|
||||
"Did-mount function loading map tile data from Open Street Map."
|
||||
[]
|
||||
(let [view (.setView (.map js/L "map") #js [55.86 -4.25] 13)
|
||||
(let [view (.setView (.map js/L "map" (clj->js {:zoomControl false})) #js [55.82 -4.25] 13)
|
||||
addresses @(subscribe [:addresses])]
|
||||
(js/console.log (str "Adding " (count addresses) " pins"))
|
||||
(doall (map #(add-map-pin (:latitude %) (:longitude %) (pin-image %) view) addresses))
|
||||
(.addTo (.tileLayer js/L osm-url
|
||||
(clj->js {:attribution osm-attrib
|
||||
:maxZoom 18}))
|
||||
view)
|
||||
;; (map #(add-map-pin (:latitude %) (:longitude %) (pin-image %) view) addresses)
|
||||
))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue