-
-
Save LispyAriaro/76865206564d3308bd8a 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
(def urls (array "http://a.tile.openstreetmap.org/${z}/${x}/${y}.png" | |
"http://b.tile.openstreetmap.org/${z}/${x}/${y}.png" | |
"http://c.tile.openstreetmap.org/${z}/${x}/${y}.png")) | |
(def OSM (js/OpenLayers.Layer.XYZ. "OSM (with buffer)" urls (extend-object! (js-obj) {"transitionEffect" "resize" | |
"buffer" 2 | |
"wrapDateLine" true | |
"sphericalMercator" true}))) | |
(def plot (js/OpenLayers.Map. (extend-object! (js-obj) {"div" "plot" | |
"layers" (array OSM) | |
"center" (array 0 0) | |
"zoom" 3 | |
"controls" (array (js/OpenLayers.Control.Navigation. (extend-object! (js-obj) {"dragPanOptions" (extend-object! (js-obj) {"enableKinetic" true})})) | |
(js/OpenLayers.Control.PanZoom.) | |
(js/OpenLayers.Control.LayerSwitcher.))}))) | |
; Geolocation | |
(defn geolocation [position] | |
(def longitude (.-longitude js/position.coords)) | |
(def latitude (.-latitude js/position.coords)) | |
(def projection (js/OpenLayers.Projection. "EPSG:4326")) | |
(def center (.transform (js/OpenLayers.LonLat. longitude latitude) projection (.getProjectionObject plot))) | |
(.setCenter plot center 18)) | |
(.getCurrentPosition js/navigator.geolocation. geolocation) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment