Skip to content

Instantly share code, notes, and snippets.

@thomas-shares
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomas-shares/62f9bb2a2fa67ec5b517 to your computer and use it in GitHub Desktop.
Save thomas-shares/62f9bb2a2fa67ec5b517 to your computer and use it in GitHub Desktop.
trying to set up a OSM map with a marker
;; The problem is that the text in :element of over-lay gets interpreted as text, not really
;; surprising at the moment as it is text, but I don't know what to do with it so that it
;; works like in the example: http://artarmstrong.com/blog/2014/10/28/openlayers-3-custom-markers-by-latitude-longitude/
(ns clojurescript-apis.core
(:require-macros [hiccups.core :as h]
[cljs.core.async.macros :as m :refer [go alt!]])
(:require [clojure.browser.repl :as repl]
[domina :as dom]
[hiccups.runtime :as hiccupsrt]
[ajax.core :refer [GET POST]]
[cljs.core.async
:as async
:refer [<! >! chan close! sliding-buffer put! alts! timeout]]
ol.Map
ol.layer.Tile
ol.layer.Vector
ol.source.OSM
ol.source.Vector
ol.View
ol.proj
ol.control.FullScreen
ol.style.Style
ol.style.Fill
ol.style.Circle
ol.style.Stroke
ol.Overlay))
(defn init-map []
(println "this is my map code!!!!")
(let [source (ol.source.OSM. #js {:layer "osm"})
raster (ol.layer.Tile. #js {:source source})
view (ol.View. #js {:center #js [37.41, 8.82]
:zoom 4
:maxZoom (get props :max-zoom 18)})
over-lay (ol.Overlay.
#js {:position (ol.proj.transform #js [-122.332071, 47.606209] ,
"EPSG:4326","EPSG:3857" )
;;;
;;; the next line should be equivalent to element: $('<img src="/img/marker.png">') but isn't at the moment.
;;; At the moment it is just text.
;;;
:element "<img src=\"/img/marker.png\">"})
map (ol.Map. #js {:layers #js [raster]
:target "demoMap"
:view view})]
(.addOverlay map over-lay ))
(println "done mapping..."))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment