File tree Expand file tree Collapse file tree 2 files changed +16
-8
lines changed
javascript/controllers/better_together
views/better_together/shared Expand file tree Collapse file tree 2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ export default class extends Controller {
77 center : String ,
88 spaces : Array ,
99 zoom : Number ,
10- extent : String
10+ extent : String ,
11+ enablePopups : { type : Boolean , default : true } , // Default to enabling popups
12+ useLabelAsPopup : { type : Boolean , default : false } // Default to using popup_html
1113 }
1214
1315 connect ( ) {
@@ -80,11 +82,16 @@ export default class extends Controller {
8082 }
8183
8284 const markers = points . map ( point => {
83- const { lat, lng, label } = point
85+ const { lat, lng, label, popup_html } = point
8486 const marker = L . marker ( [ lat , lng ] ) . addTo ( this . map )
85- if ( label ) {
86- marker . bindPopup ( label ) . openPopup ( ) // Automatically open the popup
87+
88+ if ( this . enablePopupsValue ) {
89+ const popupContent = this . useLabelAsPopupValue ? label : popup_html
90+ if ( popupContent ) {
91+ marker . bindPopup ( popupContent ) . openPopup ( ) // Automatically open the popup
92+ }
8793 }
94+
8895 return marker
8996 } )
9097
Original file line number Diff line number Diff line change 1-
2- <%# locals: (map:)%>
1+ <%# locals: (map:, enable_popups: true, use_label_as_popup: false) %>
32
43<% if map %>
54 <div class ="map " id ="<%= dom_id ( map ) %> "
65 data-controller ="better_together--map "
76 data-better_together--map-center-value ="<%= map . center_for_leaflet %> "
8- data-better_together--map-spaces-value ="<%= map . leaflet_points %> "
7+ data-better_together--map-spaces-value ="<%= map . leaflet_points . to_json %> "
98 data-better_together--map-zoom-value ="<%= map . zoom %> "
10- data-better_together--map-extent-value ="<%= map . viewport %> ">
9+ data-better_together--map-extent-value ="<%= map . viewport %> "
10+ data-better_together--map-enable-popups-value ="<%= enable_popups %> "
11+ data-better_together--map-use-label-as-popup-value ="<%= use_label_as_popup %> ">
1112 < div class ="map-controls ">
1213 < button class ="btn btn-secondary " data-action ="better_together--map#switchToOSM "> Map</ button >
1314 < button class ="btn btn-secondary " data-action ="better_together--map#switchToSatellite "> Satellite</ button >
You can’t perform that action at this time.
0 commit comments