cache labels differently in js to hopefully avoid crash in ff
This commit is contained in:
parent
5ccbb05c05
commit
04f7298122
1 changed files with 12 additions and 11 deletions
|
@ -98,8 +98,8 @@ c3nav = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
_sort_labels: function(a, b) {
|
_sort_labels: function(a, b) {
|
||||||
var result = (a.label_settings.min_zoom || -10) - (b.label_settings.min_zoom || -10);
|
var result = (a[0].label_settings.min_zoom || -10) - (b[0].label_settings.min_zoom || -10);
|
||||||
if (result === 0) result = b.label_settings.font_size - a.label_settings.font_size;
|
if (result === 0) result = b[0].label_settings.font_size - a[0].label_settings.font_size;
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
_last_time_searchable_locations_loaded: null,
|
_last_time_searchable_locations_loaded: null,
|
||||||
|
@ -119,9 +119,8 @@ c3nav = {
|
||||||
locations.push(location);
|
locations.push(location);
|
||||||
locations_by_id[location.id] = location;
|
locations_by_id[location.id] = location;
|
||||||
if (location.point && location.label_settings) {
|
if (location.point && location.label_settings) {
|
||||||
location.label = c3nav._build_location_label(location);
|
|
||||||
if (!(location.point[0] in labels)) labels[location.point[0]] = [];
|
if (!(location.point[0] in labels)) labels[location.point[0]] = [];
|
||||||
labels[location.point[0]].push(location);
|
labels[location.point[0]].push([location, c3nav._build_location_label(location)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (level_id in labels) {
|
for (level_id in labels) {
|
||||||
|
@ -324,22 +323,24 @@ c3nav = {
|
||||||
zoom = c3nav.map.getZoom();
|
zoom = c3nav.map.getZoom();
|
||||||
if (!labels) return;
|
if (!labels) return;
|
||||||
|
|
||||||
var valid_upper = [];
|
var valid_upper = [], location, label;
|
||||||
for (var location of labels) {
|
for (var item of labels) {
|
||||||
|
location = item[0];
|
||||||
|
label = item[1];
|
||||||
if (zoom < (location.label_settings.min_zoom || -10)) {
|
if (zoom < (location.label_settings.min_zoom || -10)) {
|
||||||
// since the labels are sorted by min_zoom, we can just leave here
|
// since the labels are sorted by min_zoom, we can just leave here
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (bounds.contains(location.label.getLatLng())) {
|
if (bounds.contains(label.getLatLng())) {
|
||||||
if ((location.label_settings.max_zoom || 10) > zoom) {
|
if ((location.label_settings.max_zoom || 10) > zoom) {
|
||||||
c3nav._labelLayer._maybeAddLayerToRBush(location.label);
|
c3nav._labelLayer._maybeAddLayerToRBush(label);
|
||||||
} else {
|
} else {
|
||||||
valid_upper.unshift(location);
|
valid_upper.unshift(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (location of valid_upper) {
|
for (label of valid_upper) {
|
||||||
c3nav._labelLayer._maybeAddLayerToRBush(location.label);
|
c3nav._labelLayer._maybeAddLayerToRBush(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue