' +
+ if ($tile.length == 0) {
+ $tile = $('
');
- $tile.appendTo($sidebar);
- $.ajax({
- url: '/api/dashboard/auto-tile/' + this.slug + '/',
- data: JSON.stringify(marker.feature.properties),
- contentType: 'application/json; charset=utf-8',
- type: 'POST',
- dataType: 'html',
- success: function(html) {
- if (marker.matching_tile) {
- $(marker.matching_tile).remove();
- marker.matching_tile = null;
+ $tile.appendTo($sidebar);
+ }
+
+ var marker_tile_cache = map.geojson_tile_cache[marker_tile_identifier];
+ if (marker_tile_cache && marker_tile_cache.loading) {
+ // pass
+ } else if (marker_tile_cache && marker_tile_cache.html) {
+ map_marker_tile(map, marker_tile_identifier, marker, {init: false});
+ } else {
+ map.geojson_tile_cache[marker_tile_identifier] = Object();
+ map.geojson_tile_cache[marker_tile_identifier].loading = true;
+ $.ajax({
+ url: '/api/dashboard/auto-tile/' + this.slug + '/',
+ data: JSON.stringify(marker.feature.properties),
+ contentType: 'application/json; charset=utf-8',
+ type: 'POST',
+ dataType: 'html',
+ success: function(html) {
+ map.geojson_tile_cache[marker_tile_identifier].html = html;
+ map.geojson_tile_cache[marker_tile_identifier].loading = false;
+ map_marker_tile(map, marker_tile_identifier, marker, {init: true});
}
- $tile.html(html);
- $sidebar.removeClass('empty');
- $tile[0].matching_marker = marker;
- marker.matching_tile = $tile;
- $tile.on('click', function(ev) {
- if (ev.target.nodeName != 'A') {
- var zoom_level = 18;
- if (map.getZoom() > zoom_level) {
- // no unzooming to avoid clusters reappearing (#26554)
- zoom_level = map.getZoom();
- }
- map.flyTo(marker.getLatLng(), zoom_level);
- }
- return true;
- });
- tile_counter += 1;
- if (tile_counter == counter) {
- $sidebar.removeClass('loading');
- }
- $sidebar.removeClass('empty');
- $('#empty-map-results').remove();
- }
- });
+ });
+ }
});
if (counter == 0) {
/* remove loading marker if there were no tiles */