Skip to content

Instantly share code, notes, and snippets.

@attentive
Last active August 29, 2015 14:00
Show Gist options
  • Save attentive/b3cb3041c3f837e83f98 to your computer and use it in GitHub Desktop.
Save attentive/b3cb3041c3f837e83f98 to your computer and use it in GitHub Desktop.
LeafletJS Hello World in Om and ClojureScript
(ns leaflet-helloworld
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]))
(defn map-view [_ owner]
(reify
om/IRender
(render [_]
(dom/div #js {:id "the-map"} nil))
om/IDidMount
(did-mount [_]
(let [osm-url "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
osm-attrib "Map data © OpenStreetMap contributors"]
(doto (js/L.Map. "the-map")
(.setView (js/L.LatLng. 0 0) 1)
(.addLayer (js/L.TileLayer. osm-url
#js {:minZoom 1, :maxZoom 19,
:attribution osm-attrib})))))))
@credmp
Copy link

credmp commented Feb 10, 2015

I have been looking at this to get leafletJS to work, I added the component and bound it to the om/root... however, besides creating the the-map node it doesn't do anything for me.... perhaps you can post the full source for the example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment