Skip to content

Commit

Permalink
Work on 1.0 and 0.64, refs #43
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jan 13, 2024
1 parent bcd539b commit 386d14c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions datasette_cluster_map/static/datasette-cluster-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,10 @@ const addClusterMap = (latitudeColumn, longitudeColumn) => {
if (next_url && location.protocol == "https:") {
next_url = next_url.replace(/^https?:/, "https:");
}
let total = data.count || data.filtered_table_rows_count;
if (next_url) {
percent = ` (${
Math.round((count / data.count) * 100 * 100) /
Math.round((count / total) * 100 * 100) /
100
}%)`;
// Add a control to either continue loading or pause
Expand All @@ -253,7 +254,7 @@ const addClusterMap = (latitudeColumn, longitudeColumn) => {
);
});
}
progressDiv.innerHTML = `Showing ${count.toLocaleString()} of ${data.count.toLocaleString()}${percent} `;
progressDiv.innerHTML = `Showing ${count.toLocaleString()} of ${total.toLocaleString()}${percent} `;
if (button) {
progressDiv.appendChild(button);
}
Expand Down Expand Up @@ -303,10 +304,11 @@ const addClusterMap = (latitudeColumn, longitudeColumn) => {
});
map.addLayer(markerClusterGroup);
let path = location.pathname + ".json" + location.search;
const qs = "_size=max&_labels=on&_extra=count&_extra=next_url&_shape=objects";
if (path.indexOf("?") > -1) {
path += "&_size=max&_labels=on&_extra=count&_extra=next_url";
path += "&" + qs;
} else {
path += "?_size=max&_labels=on&_extra=count&_extra=next_url";
path += "?" + qs;
}
loadMarkers(path, map, markerClusterGroup, progressDiv, 0);
};

0 comments on commit 386d14c

Please sign in to comment.