From 779eebfdfdac04c048939ceda4377620f8e29129 Mon Sep 17 00:00:00 2001 From: deanchen Date: Fri, 21 May 2021 11:06:27 +0800 Subject: [PATCH] fix: sort out utf lib name; fix problem of throwing error when pan the move, saying problem with the nearest arrow or tile unload process; --- package-lock.json | 14 +++++++------- package.json | 4 ++-- src/App.js | 2 +- src/models/Map.js | 12 ++++++++++-- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 921605c91..1462307be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5752,13 +5752,6 @@ "through": ">=2.2.7 <3" } }, - "Leaflet.UTFGrid": { - "version": "git+https://github.com/dadiorchen/Leaflet.UTFGrid.git#8fef90db412ce4b7f93c0653929dd23ad8459ac6", - "from": "git+https://github.com/dadiorchen/Leaflet.UTFGrid.git", - "requires": { - "corslite": "0.0.7" - } - }, "abab": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.3.tgz", @@ -14068,6 +14061,13 @@ "resolved": "https://registry.npmjs.org/leaflet/-/leaflet-1.7.1.tgz", "integrity": "sha512-/xwPEBidtg69Q3HlqPdU3DnrXQOvQU/CCHA1tcDQVzOwm91YMYaILjNp7L4Eaw5Z4sOYdbBz6koWyibppd8Zqw==" }, + "leaflet-utfgrid": { + "version": "git+https://github.com/dadiorchen/Leaflet.UTFGrid.git#58cfdeb3b06ddeb88020d0bff73138085a7ca9a9", + "from": "git+https://github.com/dadiorchen/Leaflet.UTFGrid.git", + "requires": { + "corslite": "0.0.7" + } + }, "leaflet.gridlayer.googlemutant": { "version": "0.12.1", "resolved": "https://registry.npmjs.org/leaflet.gridlayer.googlemutant/-/leaflet.gridlayer.googlemutant-0.12.1.tgz", diff --git a/package.json b/package.json index 8d0ac075a..ac9b5334e 100644 --- a/package.json +++ b/package.json @@ -11,14 +11,14 @@ "@testing-library/user-event": "^7.1.2", "expect-runtime": "^0.4.0", "leaflet": "^1.7.1", + "leaflet-utfgrid": "git+https://github.com/dadiorchen/Leaflet.UTFGrid.git", "leaflet.gridlayer.googlemutant": "^0.12.1", "loglevel": "^1.7.0", "moment": "^2.29.1", "react": "^16.13.1", "react-dom": "^16.13.1", "react-scripts": "3.4.1", - "source-map-explorer": "^2.5.0", - "Leaflet.UTFGrid": "git+https://github.com/dadiorchen/Leaflet.UTFGrid.git" + "source-map-explorer": "^2.5.0" }, "scripts": { "start": "react-scripts start", diff --git a/src/App.js b/src/App.js index eb33d3b5f..760be1abf 100644 --- a/src/App.js +++ b/src/App.js @@ -15,7 +15,7 @@ import log from "loglevel"; import Timeline from "./components/Timeline"; import 'leaflet'; import 'leaflet/dist/leaflet.css'; -import "Leaflet.UTFGrid/L.UTFGrid.js"; +import "leaflet-utfgrid/L.UTFGrid.js"; import 'leaflet.gridlayer.googlemutant'; import Map from "./models/Map"; import {parseMapName} from "./utils"; diff --git a/src/models/Map.js b/src/models/Map.js index 758d543c5..0d60e82a0 100644 --- a/src/models/Map.js +++ b/src/models/Map.js @@ -882,8 +882,12 @@ export default class Map{ }else{ log.info("no marker"); const nearest = await this.getNearest(); - const placement = this.calculatePlacement(nearest); - this.onFindNearestAt && this.onFindNearestAt(placement); + if(nearest){ + const placement = this.calculatePlacement(nearest); + this.onFindNearestAt && this.onFindNearestAt(placement); + }else{ + log.warn("Can't get the nearest:", nearest); + } } } @@ -894,6 +898,10 @@ export default class Map{ const res = await this.requester.request({ url: `${this.apiServerUrl}nearest?zoom_level=${zoom_level}&lat=${center.lat}&lng=${center.lng}`, }); + if(!res){ + log.warn("Return undefined trying to get nearest, the api return null"); + return; + } let {nearest} = res; nearest = nearest? { lat: nearest.coordinates[1],