Skip to content

Instantly share code, notes, and snippets.

Created Jan 12, 2015
What would you like to do?
Sample ClojureScritp app with Leaflet
(ns site
(:require [site.utils :refer [L esri utilTemplate ctr zoom]]))
(defn parkStyle [_]
(clj->js { :color "#70ca49", :weight 2 }))
(def opts (clj->js { :style parkStyle }))
(def parkUrl "")
(def popupTemplate "<h3>{NAME}</h3>{ACRES} Acres<br><small>Property ID: {PROPERTYID}<small>")
(defn boundTemplate [feature]
(utilTemplate popupTemplate (.-properties feature)))
(defn bindPopup [f]
(.bindPopup f boundTemplate))
(defn basemap [m]
(let [b (-> esri (.basemapLayer "Gray")
(.addTo m))] m))
(defn fLayer [options m]
(let [f (-> esri (.featureLayer parkUrl options)
(.addTo m))], f))
(defn loadMap [_]
(let [m (-> L (.map "map")
(.setView ctr zoom))] m))
(defn ^:export init [_]
((comp bindPopup (partial fLayer opts) basemap loadMap)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment