Fix map markers navigation for keyboard users

By using the bindPopup function instead of the click event
popups work when using the keyboard.

Note that now we are loading all the map markers in the first
request in a single query to the database (needed when there
is a lot or markers to show). Because of that we removed the
AJAX endpoint.
This commit is contained in:
Senén Rodero Rodríguez
2023-06-16 15:48:57 +02:00
parent 2b0a812543
commit 3fa3c90db6
7 changed files with 28 additions and 39 deletions

View File

@@ -172,7 +172,7 @@
if (App.Map.validCoordinates(coordinates)) {
marker = createMarker(coordinates.lat, coordinates.long);
marker.options.id = coordinates.investment_id;
marker.on("click", App.Map.openMarkerPopup);
marker.bindPopup(App.Map.getPopupContent(coordinates));
}
});
}
@@ -217,19 +217,8 @@
polygon.addTo(map);
},
openMarkerPopup: function(e) {
var marker = e.target;
$.ajax("/investments/" + marker.options.id + "/json_data", {
type: "GET",
dataType: "json",
success: function(data) {
e.target.bindPopup(App.Map.getPopupContent(data)).openPopup();
}
});
},
getPopupContent: function(data) {
return "<a href='/budgets/" + data.budget_id + "/investments/" + data.investment_id + "'>" +
data.investment_title + "</a>";
return "<a href='" + data.link + "'>" + data.title + "</a>";
},
validZoom: function(zoom) {
return App.Map.isNumeric(zoom);