helix

https://github.com/Lokeh/helix
Christopher Stone 2020-11-02T00:48:16.126300Z

I feel a bit awkward asking you for help again. But once again I am stuck; I am able to display a map, but, I am unsure on how to create an instance of that map so that I can access methods on it after it has been created. Every time i try to store an instance of it as a let binding, and try to pass that to use-effect I get an error asking me if I meant to pass it a function instead of a symbol? I really don't know what to do, please advise.

lilactown 2020-11-02T01:17:23.127100Z

Can you paste what you’ve tried so far?

lilactown 2020-11-02T01:17:40.127500Z

I’ll help as much as I can 🙂

Christopher Stone 2020-11-02T01:18:24.127700Z

(defnc customer-map [] (let [osm-layer (L/tileLayer osm-url copy-osm) home-marker (L/marker default-center) collection-points @(rf/subscribe [:collection-points]) collection-point-markers (for [point collection-points] (L/marker (:latlng point))) layers (L/layerGroup [home-marker collection-point-markers]) map-element (js/document.getElementById "map")] (prn (obj->clj layers)) (use-effect :once (L/map "map" (clj->js {:center default-center :zoom 9 :zoomControl false :layers [osm-layer layers] })))) (d/div {:id "map" :style {:min-height "300px"}}) )

Christopher Stone 2020-11-02T01:19:02.128400Z

its displaying as is... but if I change it to this:

Christopher Stone 2020-11-02T01:19:57.128600Z

(defnc customer-map [] (let [osm-layer (L/tileLayer osm-url copy-osm) home-marker (L/marker default-center) collection-points @(rf/subscribe [:collection-points]) collection-point-markers (for [point collection-points] (L/marker (:latlng point))) layers (L/layerGroup [home-marker collection-point-markers]) map-element (js/document.getElementById "map") the-map (L/map "map" (clj->js {:center default-center :zoom 9 :zoomControl false :layers [osm-layer layers] }))] (prn (obj->clj layers)) (use-effect :once the-map)) (d/div {:id "map" :style {:min-height "300px"}}) )

Christopher Stone 2020-11-02T01:20:19.128900Z

I have problems

Christopher Stone 2020-11-02T01:28:55.130600Z

I need to be able to store the map as an instance because it has methods to do things like flyTo another location or addTo, to add things to the map... etc...

ordnungswidrig 2020-11-02T11:48:50.131600Z

@alpha_command I think you need the ref attribute off react. This allows you to actually access the instance. See https://github.com/reagent-project/reagent/blob/master/doc/FAQ/UsingRefs.md

Christopher Stone 2020-11-02T11:57:03.133300Z

Thanks for your thoughtful answer, It has made clear a few distinctions, I shall explore this much more, thanks again 🙂