Last active
July 13, 2016 07:39
-
-
Save nha/afb3c839555a4ff53bfa47806b6b4d2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns carder-devcards.map | |
(: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 | |
component | |
(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}.tile.osm.org/{z}/{x}/{y}.png" | |
:attribution "© <a href=\"http://osm.org/copyright\">OpenStreetMap</a> contributors"}) | |
mk (marker {:position pos})] | |
(leaflet-map {:center pos :zoom zoom} | |
tl | |
mk | |
))) | |
{:pos [51.505, -0.09] | |
:zoom 13} | |
{:header true}) | |
;; result screenshot https://infinit.io/_/3f9V2NU |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment