 (ns gtfve.maps
   (:require-macros [cljs.core.async.macros :refer [go go-loop]])
-  (:require [reagent.core :as r :refer [atom]]
-            [secretary.core :as secretary :include-macros true]
+  (:require [om.core :as om]
+            [sablono.core :as html :refer-macros [html]]
             [cljs.core.async :as async :refer [put! chan <! close!]]
             [goog.events :as events]
             [goog.history.EventType :as EventType]

                                      :strokeOpacity 1.0
                                      :strokeWeight 2}))))

(defn r-map-object [class opts gmap]
  (let [obj (class. (clj->js @opts))]
    (r/create-class
     {:component-did-mount (fn [this]
                             (let [[_ _ opts gmap] (r/argv this)
                                   m-opts (merge @opts {:map gmap})]
                               (.setOptions obj (clj->js m-opts))))
      :component-did-update (fn [this]
                              (let [[_ _ opts gmap] (r/argv this)
                                    m-opts (merge @opts {:map gmap})]
                                (.setOptions obj (clj->js m-opts))))
      :component-will-unmount (fn [this]
                                (.setMap obj nil))
      :component-function (fn [class opts gmap]
                            [:noscript])})))

(defn r-marker [opts gmap]
  (let [marker (Maps.Marker. (clj->js @opts))]
    (r/create-class
     {:component-did-mount (fn [this]
                             (let [[_ opts gmap] (r/argv this)
                                   m-opts (merge @opts {:map gmap})]
                               (.setOptions marker (clj->js m-opts))))
      :component-did-update (fn [this]
                              (let [[_ opts gmap] (r/argv this)
                                    m-opts (merge @opts {:map gmap})]
                                (.setOptions marker (clj->js m-opts))))
      :component-will-unmount (fn [this]
                                (.setMap marker nil))
      :component-function (fn [opts gmap]
                            [:noscript])})))

(defn r-polyline [opts gmap]
  (let [polyline (Maps.Polyline. (clj->js @opts))]
    (r/create-class
     {:component-function (fn [opts gmap]
                            [:noscript])})))

(defn map-listen
  "Return a channel listening on events of type in obj."

      :component-function (fn [state]
                            [:div {:id :map-canvas
                                   :style {:height "100%"
                                           :width "100%"}}
                             (doall
                              (for [{id :route/id
                                     :as route-data} (:routes @state)]
