forked from trent_larson/crowd-funder-for-time-pwa
fix centering of numbers on map markers, fix recenter after first drag
This commit is contained in:
@@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
|
||||||
## [0.3.43] - 2024.12.30
|
## [0.3.44] - 2024.12.31
|
||||||
### Added
|
### Added
|
||||||
- Project counts on a map
|
- Project counts on a map
|
||||||
|
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "TimeSafari",
|
"name": "TimeSafari",
|
||||||
"version": "0.3.43",
|
"version": "0.3.44",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "TimeSafari",
|
"name": "TimeSafari",
|
||||||
"version": "0.3.43",
|
"version": "0.3.44",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@capacitor/android": "^6.1.2",
|
"@capacitor/android": "^6.1.2",
|
||||||
"@capacitor/cli": "^6.1.2",
|
"@capacitor/cli": "^6.1.2",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "TimeSafari",
|
"name": "TimeSafari",
|
||||||
"version": "0.3.43",
|
"version": "0.3.44",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"serve": "vite preview",
|
"serve": "vite preview",
|
||||||
|
|||||||
@@ -121,10 +121,9 @@
|
|||||||
<div class="mt-4 h-96 w-5/6 mx-auto">
|
<div class="mt-4 h-96 w-5/6 mx-auto">
|
||||||
<l-map
|
<l-map
|
||||||
ref="projectMap"
|
ref="projectMap"
|
||||||
:center="[localCenterLat, localCenterLong]"
|
|
||||||
:zoom="2"
|
|
||||||
@ready="onMapReady"
|
@ready="onMapReady"
|
||||||
@moveend="onMoveEnd"
|
@moveend="onMoveEnd"
|
||||||
|
@movestart="onMoveStart"
|
||||||
@zoomend="onZoomEnd"
|
@zoomend="onZoomEnd"
|
||||||
@zoomstart="onZoomStart"
|
@zoomstart="onZoomStart"
|
||||||
>
|
>
|
||||||
@@ -498,12 +497,18 @@ export default class DiscoverView extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async onMapReady(map: L.Map) {
|
async onMapReady(map: L.Map) {
|
||||||
|
// doing this here instead of the l-map element avoids a recentering after the first drag
|
||||||
|
map.setView([this.localCenterLat, this.localCenterLong], 2);
|
||||||
this.requestTiles(map);
|
this.requestTiles(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tried but failed to use other vue-leaflet methods update:zoom and update:bounds
|
// Tried but failed to use other vue-leaflet methods update:zoom and update:bounds
|
||||||
// To access the from this.$refs, use this.$refs.projectMap.mapObject
|
// To access the from this.$refs, use this.$refs.projectMap.mapObject
|
||||||
|
|
||||||
|
onMoveStart(/* event: L.LocationEvent */) {
|
||||||
|
// don't remove markers because they follow the map when moving (and the experience is jarring)
|
||||||
|
}
|
||||||
|
|
||||||
async onMoveEnd(event: L.LocationEvent) {
|
async onMoveEnd(event: L.LocationEvent) {
|
||||||
if (this.zoomedSoDoNotMove) {
|
if (this.zoomedSoDoNotMove) {
|
||||||
// since a zoom triggers a moveend, too, don't duplicate a tile request
|
// since a zoom triggers a moveend, too, don't duplicate a tile request
|
||||||
@@ -514,12 +519,16 @@ export default class DiscoverView extends Vue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async onZoomEnd(event: L.LocationEvent) {
|
onZoomStart(/* event: L.LocationEvent */) {
|
||||||
await this.requestTiles(event.target);
|
// remove markers because otherwise they jump around at zoom end
|
||||||
|
Object.values(this.markers).forEach((marker) => marker.remove());
|
||||||
|
this.markers = {};
|
||||||
|
|
||||||
|
this.zoomedSoDoNotMove = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onZoomStart(/* event: L.LocationEvent */) {
|
async onZoomEnd(event: L.LocationEvent) {
|
||||||
this.zoomedSoDoNotMove = true;
|
await this.requestTiles(event.target);
|
||||||
}
|
}
|
||||||
|
|
||||||
async requestTiles(targetMap: L.Map) {
|
async requestTiles(targetMap: L.Map) {
|
||||||
@@ -535,10 +544,10 @@ export default class DiscoverView extends Vue {
|
|||||||
this.apiServer + "/api/v2/report/planCountsByBBox?" + queryParams,
|
this.apiServer + "/api/v2/report/planCountsByBBox?" + queryParams,
|
||||||
);
|
);
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
|
Object.values(this.markers).forEach((marker) => marker.remove());
|
||||||
|
this.markers = {};
|
||||||
const results = await response.json();
|
const results = await response.json();
|
||||||
if (results.data?.tiles?.length > 0) {
|
if (results.data?.tiles?.length > 0) {
|
||||||
Object.values(this.markers).forEach((marker) => marker.remove());
|
|
||||||
this.markers = {};
|
|
||||||
for (const tile of results.data.tiles) {
|
for (const tile of results.data.tiles) {
|
||||||
const pinLat = (tile.minFoundLat + tile.maxFoundLat) / 2;
|
const pinLat = (tile.minFoundLat + tile.maxFoundLat) / 2;
|
||||||
const pinLon = (tile.minFoundLon + tile.maxFoundLon) / 2;
|
const pinLon = (tile.minFoundLon + tile.maxFoundLon) / 2;
|
||||||
@@ -560,9 +569,7 @@ export default class DiscoverView extends Vue {
|
|||||||
};
|
};
|
||||||
this.searchLocal();
|
this.searchLocal();
|
||||||
});
|
});
|
||||||
this.markers[
|
this.markers["" + tile.indexLat + "X" + tile.indexLon] = marker;
|
||||||
"" + tile.indexLat + "X" + tile.indexLon + "*" + tile.recordCount
|
|
||||||
] = marker;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await this.searchLocal();
|
await this.searchLocal();
|
||||||
@@ -664,6 +671,7 @@ export default class DiscoverView extends Vue {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
text-align: center;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: white;
|
color: white;
|
||||||
|
|||||||
Reference in New Issue
Block a user