Skip to content

Commit f963451

Browse files
committed
Only open map point popup if there is only a single point
1 parent 5b3ecf8 commit f963451

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

app/javascript/controllers/better_together/map_controller.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,11 @@ export default class extends Controller {
8585
const { lat, lng, label, popup_html } = point
8686
const marker = L.marker([lat, lng]).addTo(this.map)
8787

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-
}
88+
const popupContent = this.useLabelAsPopupValue ? label : popup_html
89+
const popup = marker.bindPopup(popupContent)
90+
91+
if (points.length == 1 && this.enablePopupsValue && popupContent) {
92+
popup.openPopup() // Automatically open the popup
9393
}
9494

9595
return marker

0 commit comments

Comments
 (0)