nbn-upgrade-map
nbn-upgrade-map copied to clipboard
Use geographic bounds on wesbite
A very hacky version, need to find a better way to deal with this many markers
// download suburb list
var results = [];
$.ajax({
url: "https://raw.githubusercontent.com/LukePrior/nbn-upgrade-map/main/results/results.json",
async: false,
dataType: 'json',
success: function (data) {
results = data["suburbs"];
}
});
var bounds = {}
$.ajax({
url: "https://raw.githubusercontent.com/LukePrior/nbn-upgrade-map/main/results/suburb-extents.json",
async: false,
dataType: 'json',
success: function (data) {
bounds = data;
}
});
current_sububrs = [];
// on map pan
map.on("moveend", function() {
if (map.getZoom() > 13) {
for (state in bounds) {
for (suburb in bounds[state]) {
// check if bounds are in view
mapbounds = map.getBounds();
if (mapbounds.contains(bounds[state][suburb])) {
for (result in results) {
if (results[result]["internal"] == suburb && results[result]["state"] == state) {
if (current_sububrs.includes((state + suburb).toLowerCase())) {
continue;
}
current_sububrs.push((state + suburb).toLowerCase());
loadSuburb("https://raw.githubusercontent.com/LukePrior/nbn-upgrade-map/main/results/" + state + "/" + results[result]["file"] + ".geojson")
}
}
}
}
}
}
});
Recent PR adds this to combined results. I don't know which is better - doing it client-side (like this) or in pre-generated JSON like https://github.com/LukePrior/nbn-upgrade-map/pull/178
Yeah I'm mainly considering how it'll effect initial load time because the site needs to fetch results before dropdown can be populated
CPU time vs download time. Depends on your capacity for each.