Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@oskarkv
Created September 2, 2021 16:52
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 oskarkv/1efa76628224ceeb23704211fb687c33 to your computer and use it in GitHub Desktop.
Save oskarkv/1efa76628224ceeb23704211fb687c33 to your computer and use it in GitHub Desktop.
(defn google-map-component [arg arg2]
(let [gmap (atom nil)
update (fn [comp]
(println "===================")
(println (reag/props comp))
(println arg)
(println arg2)
(println @arg2)
(println comp)
(js/console.dir comp)
;; (let [{:keys [latitude longitude]} (reagent/props comp)
;; latlng (js/google.maps.LatLng. latitude longitude)]
;; (.setPosition (:marker @gmap) latlng)
;; (.panTo (:map @gmap) latlng)))]
)]
(reag/create-class
{:reagent-render (fn [] [:div#map])
:component-did-mount (fn [comp]
(let [mapdiv (element-by-id "map")
gm (create-map mapdiv 13)]
(doseq [[k v] data]
(create-marker
gm (vec->lnglat
(get-in v [:geometry :coordinates]))))
(reset! gmap gm)
(update comp)))
:component-did-update update
:display-name "google-map-component"})))
(defn map-view []
(let [selected (rf/subscribe [:selected])
s @(rf/subscribe [:selected])]
(fn []
[google-map-component @selected selected #_(-> @selected
data
:geometry
:coordinates
vec->lnglat
js->clj
(assoc :lat (rand))
clj->js)])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment