Skip to content

Commit 423faa6

Browse files
committed
Ensure map is present before trying to render it
1 parent 5e47c5a commit 423faa6

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed
Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11

22
<%# locals: (mappable:, map: mappable.map)%>
33

4-
<div class="map" id="<%= dom_id(mappable, :map) %>"
5-
data-controller="better_together--map"
6-
data-better_together--map-center-value="<%= map.center_for_leaflet %>"
7-
data-better_together--map-spaces-value="<%= map.leaflet_points %>"
8-
data-better_together--map-zoom-value="<%= map.zoom %>"
9-
data-better_together--map-extent-value="<%= map.viewport %>">
10-
<div class="map-controls">
11-
<button class="btn btn-secondary" data-action="better_together--map#switchToOSM">OpenStreetMap</button>
12-
<button class="btn btn-secondary" data-action="better_together--map#switchToSatellite">Satellite</button>
13-
<button class="btn btn-secondary" data-action="better_together--map#enableGeolocation">Geolocate Me</button>
4+
<% if map %>
5+
<div class="map" id="<%= dom_id(mappable, :map) %>"
6+
data-controller="better_together--map"
7+
data-better_together--map-center-value="<%= map.center_for_leaflet %>"
8+
data-better_together--map-spaces-value="<%= map.leaflet_points %>"
9+
data-better_together--map-zoom-value="<%= map.zoom %>"
10+
data-better_together--map-extent-value="<%= map.viewport %>">
11+
<div class="map-controls">
12+
<button class="btn btn-secondary" data-action="better_together--map#switchToOSM">OpenStreetMap</button>
13+
<button class="btn btn-secondary" data-action="better_together--map#switchToSatellite">Satellite</button>
14+
<button class="btn btn-secondary" data-action="better_together--map#enableGeolocation">Geolocate Me</button>
15+
</div>
1416
</div>
15-
</div>
17+
<% end %>

0 commit comments

Comments
 (0)