Ensure that `:initialCenterCoordinate` attribute gets the correct data
Mapview component accepts the `:initialCenterCoordinate` which always must have longitude and latitude attributes. This ensures that they will always be present even when they are missing from the map passed retreived from the app state.
This commit is contained in:
parent
280466f5d6
commit
41429cf1ed
|
@ -24,6 +24,10 @@
|
||||||
#(reset! cur-loc-geocoded nil))
|
#(reset! cur-loc-geocoded nil))
|
||||||
true)))
|
true)))
|
||||||
|
|
||||||
|
(defn get-coord [{:keys [latitude longitude]}]
|
||||||
|
{:latitude (or latitude 0)
|
||||||
|
:longitude (or longitude 0)})
|
||||||
|
|
||||||
(defn place-item [{:keys [title address pin-style] [latitude longitude] :center}]
|
(defn place-item [{:keys [title address pin-style] [latitude longitude] :center}]
|
||||||
[touchable-highlight {:on-press #(do
|
[touchable-highlight {:on-press #(do
|
||||||
(dispatch [:set-command-argument [0
|
(dispatch [:set-command-argument [0
|
||||||
|
@ -58,7 +62,7 @@
|
||||||
(dispatch [:set-chat-seq-arg-input-text "Dropped pin"])
|
(dispatch [:set-chat-seq-arg-input-text "Dropped pin"])
|
||||||
(dispatch [:chat-input-blur :seq-input-ref])
|
(dispatch [:chat-input-blur :seq-input-ref])
|
||||||
(dispatch [:load-chat-parameter-box (:command command)]))
|
(dispatch [:load-chat-parameter-box (:command command)]))
|
||||||
:initialCenterCoordinate coord
|
:initialCenterCoordinate (get-coord coord)
|
||||||
:showsUserLocation true
|
:showsUserLocation true
|
||||||
:initialZoomLevel 10
|
:initialZoomLevel 10
|
||||||
:logoIsHidden true
|
:logoIsHidden true
|
||||||
|
@ -140,10 +144,11 @@
|
||||||
result (reaction (when @pin-location (get-places @pin-location pin-geolocation)))
|
result (reaction (when @pin-location (get-places @pin-location pin-geolocation)))
|
||||||
result2 (reaction (when @pin-location (get-places @pin-location pin-nearby true)))]
|
result2 (reaction (when @pin-location (get-places @pin-location pin-nearby true)))]
|
||||||
(fn []
|
(fn []
|
||||||
(let [_ @result _ @result2]
|
(let [_ @result _ @result2
|
||||||
|
coord (select-keys (:coords geolocation) [:latitude :longitude])]
|
||||||
[view
|
[view
|
||||||
[view
|
[view
|
||||||
[mapview {:initial-center-coordinate (select-keys (:coords geolocation) [:latitude :longitude])
|
[mapview {:initial-center-coordinate (get-coord coord)
|
||||||
:initialZoomLevel 10
|
:initialZoomLevel 10
|
||||||
:onRegionDidChange #(reset! pin-location (js->clj % :keywordize-keys true))
|
:onRegionDidChange #(reset! pin-location (js->clj % :keywordize-keys true))
|
||||||
:logoIsHidden true
|
:logoIsHidden true
|
||||||
|
|
Loading…
Reference in New Issue