Created
September 2, 2021 16:52
-
-
Save oskarkv/1efa76628224ceeb23704211fb687c33 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
(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