         nil
         old-markers))))
 
-(defn gen-new-markers [owner]
-  (let [all-markers (create-markers owner)]
+(defn gen-new-markers [owner transit-journey]
+  (let [all-markers (create-markers owner transit-journey)]
     (om/set-state! owner :all-markers all-markers)))
 
+(defn valid-journey? [journey]
+  (and (not (empty? (-> journey :start-place :coords))) (not (empty? (-> journey :end-place :coords)))))
+
 (defn update-journey-plan [owner]
-  (let [[current-city journey] (om/get-props owner)
+  (let [{:keys [current-city journey transit-journey]} (om/get-props owner)
         waypoints (attractions/get-waypoints
                     (-> journey :waypoint-attraction-ids)
                     (-> current-city :attractions :data)) ]
-    (when (and (not (empty? (-> journey :start-place :coords))) (not (empty? (-> journey :end-place :coords))))
+    (when (valid-journey? journey)
       (.route
         (om/get-state owner :google-directions-service)
         #js {:origin (-> journey :start-place :coords clj->js)

        []
        all-directions))))

(defn create-renderers [owner all-directions]
  (reduce
    (fn [renderers [index directions]]
      (let [renderer (js/google.maps.DirectionsRenderer.
                       #js {:polylineOptions #js {:strokeColor (next-color index)}
                            :suppressMarkers true})]
        (.setMap renderer (om/get-state owner :google-map))
        (.setDirections renderer (clj->js (:directions directions)))
        (conj renderers renderer)))
    []
    (map vector (range) all-directions)))

(defn gen-new-renderers [owner waypoints journey all-directions]
  (let [all-renderers (create-renderers owner all-directions)]
    (om/set-state! owner :all-renderers all-renderers)
    (om/update!
      (models/transit-journey)
      (annotate-directions
        (-> journey :start-place :address)
        (-> journey :end-place :address)
        waypoints
        all-directions))))

(defn get-start-location [transit-directions]
  (-> transit-directions :directions :routes (get 0) :legs (get 0) :start_location))

(defn get-end-location [transit-directions]
  (-> transit-directions :directions :routes (get 0) :legs (get 0) :end_location))

(defn create-markers [owner]
  (reduce
    (fn [partial-markers [place-id location]]
      (conj
        partial-markers
        (js/google.maps.Marker.
          #js {:position location 
               :map (om/get-state owner :google-map)
               :title (str place-id) 
               :label (str (inc place-id)) 
               })))
    []
    (vec 
      (map vector
           "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
           (conj
             (vec (map get-start-location (models/transit-journey)))
             (get-end-location (last (models/transit-journey))))))))

;; TODO - make sure that this doesn't cause a memory leak
;; since I don't actually delete the object

                                                            (-> current-city :attractions :data)])]]
              [:div {:class "ui fourteen wide column row basic segment"}
               [:div {:class "fourteen wide column"}
                (om/build attraction-map-view [current-city journey transit-journey])]]
              ]]))))
