From d33e126b2624c36501d3b380634040c660b26800 Mon Sep 17 00:00:00 2001 From: Wisdom Ebong Date: Thu, 28 Jul 2022 11:29:51 +0100 Subject: [PATCH 1/6] fix: map jumps around when loading map view --- legacy/app/map/post-view-map.directive.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/legacy/app/map/post-view-map.directive.js b/legacy/app/map/post-view-map.directive.js index 325e5cdf80..a74137d1f7 100644 --- a/legacy/app/map/post-view-map.directive.js +++ b/legacy/app/map/post-view-map.directive.js @@ -77,32 +77,30 @@ function PostViewMap(PostEndpoint, Maps, _, PostFilters, L, $q, $rootScope, $com } } - function addPostsToMap(posts) { + function addPostsToMap(posts, isFirstOrLastPostChunk = false) { var geojson = L.geoJson(posts, { pointToLayer: Maps.pointToLayer, onEachFeature: onEachFeature }); if (map.options.clustering) { - markers = markers ? markers : L.markerClusterGroup({ maxClusterRadius: map.options.cluster_radius }); - // This has to be done individually. - // Using clusterLayer.addLayers() breaks the clustering. - // Need to investigate as this should have been fixing in v1.0.0 - angular.forEach(geojson.getLayers(), function (layer) { - markers.addLayer(layer); - }); + + // Apparently cluster.addLayers doesn't break clustering anymore + markers.addLayers(geojson.getLayers()); } else { markers = geojson; } markers.addTo(map); geoJsonLayers.push(markers); - if (posts.features.length > 0) { + // Adjust map boundaries only when post fetching is first or last batch + if (posts.features.length > 0 && isFirstOrLastPostChunk) { map.fitBounds(geojson.getBounds()); } + // Focus map on data points but.. // Avoid zooming further than 15 (particularly when we just have a single point) if (map.getZoom() > 15) { @@ -193,7 +191,7 @@ function PostViewMap(PostEndpoint, Maps, _, PostFilters, L, $q, $rootScope, $com return getFirstPostChunk.$promise.then(function (posts) { // Adding the first 200 posts to map here and getting the totals $scope.stats.filteredPosts = posts.total; - addPostsToMap(posts) + addPostsToMap(posts, true) // Moving on to request rest of the posts if (posts.total > limit) { @@ -202,7 +200,8 @@ function PostViewMap(PostEndpoint, Maps, _, PostFilters, L, $q, $rootScope, $com let request = PostEndpoint.geojson(conditions); currentGeoJsonRequests.push(request); request.$promise.then(result => { - addPostsToMap(result) + var isLastPostChunk = posts.total === i; + addPostsToMap(result, isLastPostChunk) }); } From b2cea84a6487ec5eea31d6a5189f3a9df85738e7 Mon Sep 17 00:00:00 2001 From: Wisdom Ebong Date: Thu, 28 Jul 2022 11:29:51 +0100 Subject: [PATCH 2/6] fix: map jumps around when loading map view --- legacy/app/map/post-view-map.directive.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/legacy/app/map/post-view-map.directive.js b/legacy/app/map/post-view-map.directive.js index 325e5cdf80..a768977d40 100644 --- a/legacy/app/map/post-view-map.directive.js +++ b/legacy/app/map/post-view-map.directive.js @@ -77,32 +77,30 @@ function PostViewMap(PostEndpoint, Maps, _, PostFilters, L, $q, $rootScope, $com } } - function addPostsToMap(posts) { + function addPostsToMap(posts, shouldFitMapBoundary = true) { var geojson = L.geoJson(posts, { pointToLayer: Maps.pointToLayer, onEachFeature: onEachFeature }); if (map.options.clustering) { - markers = markers ? markers : L.markerClusterGroup({ maxClusterRadius: map.options.cluster_radius }); - // This has to be done individually. - // Using clusterLayer.addLayers() breaks the clustering. - // Need to investigate as this should have been fixing in v1.0.0 - angular.forEach(geojson.getLayers(), function (layer) { - markers.addLayer(layer); - }); + + // Apparently cluster.addLayers doesn't break clustering anymore + markers.addLayers(geojson.getLayers()); } else { markers = geojson; } markers.addTo(map); geoJsonLayers.push(markers); - if (posts.features.length > 0) { - map.fitBounds(geojson.getBounds()); + // Adjust map boundaries only when post fetching is first or last batch + if (posts.features.length > 0 && shouldFitMapBoundary) { + map.fitBounds(markers.getBounds()); } + // Focus map on data points but.. // Avoid zooming further than 15 (particularly when we just have a single point) if (map.getZoom() > 15) { @@ -202,9 +200,9 @@ function PostViewMap(PostEndpoint, Maps, _, PostFilters, L, $q, $rootScope, $com let request = PostEndpoint.geojson(conditions); currentGeoJsonRequests.push(request); request.$promise.then(result => { + // var isLastPostChunk = i + limit > posts.total; addPostsToMap(result) }); - } } }); From 4f58f71b1d6471f73ecf01a7e06b10a05122c3e5 Mon Sep 17 00:00:00 2001 From: Wisdom Ebong <30173059+webong@users.noreply.github.com> Date: Mon, 8 Aug 2022 12:24:35 +0100 Subject: [PATCH 3/6] Update post-messages-reply.html Increase the max length of the reply textbox to 160 --- .../app/data/common/post-edit-detail/post-messages-reply.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/legacy/app/data/common/post-edit-detail/post-messages-reply.html b/legacy/app/data/common/post-edit-detail/post-messages-reply.html index 78373a2dab..5c0f131e78 100644 --- a/legacy/app/data/common/post-edit-detail/post-messages-reply.html +++ b/legacy/app/data/common/post-edit-detail/post-messages-reply.html @@ -2,7 +2,7 @@
- +