Created
January 12, 2015 15:53
-
-
Save odoe/a299d07646ba97f13760 to your computer and use it in GitHub Desktop.
Sample ClojureScritp app with Leaflet
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 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 "http://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Portland_Parks/FeatureServer/0") | |
(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