Skip to content

Instantly share code, notes, and snippets.

Last active Jul 13, 2016
What would you like to do?
(:require [taoensso.timbre :as timbre]
[cljsjs.react-leaflet] ;; js/ReactLeaflet
(:require-macros [devcards.core :as dc :refer [defcard defcard-doc defcard-om-next noframe-doc deftest dom-node]]))
(defn build
([component props]
(build component props (array)))
([component props & children]
(.createElement js/React
(clj->js props)
(array children))))
(def tile-layer (partial build js/ReactLeaflet.TileLayer))
(def leaflet-map (partial build js/ReactLeaflet.Map))
(def marker (partial build js/ReactLeaflet.Marker))
(def popup (partial build js/ReactLeaflet.Popup))
(defcard simple-leaflet
(fn [state]
(let [{:keys [pos zoom] :as st} @state
tl (tile-layer {:url "http://{s}{z}/{x}/{y}.png"
:attribution "&copy; <a href=\"\">OpenStreetMap</a> contributors"})
mk (marker {:position pos})]
(leaflet-map {:center pos :zoom zoom}
{:pos [51.505, -0.09]
:zoom 13}
{:header true})
;; result screenshot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment