kopia lustrzana https://github.com/FacilMap/facilmap
Fix long click behaviour
rodzic
1087b7cd64
commit
283a9a8cc1
|
@ -64,26 +64,13 @@ export default class ClickMarker extends Vue {
|
|||
|
||||
async handleMapLongClick(pos: Point): Promise<void> {
|
||||
const now = Date.now();
|
||||
if (now - this.lastClick < 500) {
|
||||
// Hacky solution to avoid markers being created when the user double-clicks the map. If multiple clicks happen less than 500 ms from each
|
||||
// other, all those clicks are ignored.
|
||||
this.lastClick = now;
|
||||
return;
|
||||
}
|
||||
|
||||
this.lastClick = now;
|
||||
|
||||
const [results] = await Promise.all([
|
||||
this.client.find({
|
||||
query: `geo:${round(pos.lat, 5)},${round(pos.lon, 5)}?z=${this.mapContext.zoom}`,
|
||||
loadUrls: false,
|
||||
elevation: true
|
||||
}),
|
||||
new Promise((resolve) => {
|
||||
// Specify the minimum time the search will take to allow for some time for the double-click detection
|
||||
setTimeout(resolve, 500);
|
||||
})
|
||||
]);
|
||||
const results = await this.client.find({
|
||||
query: `geo:${round(pos.lat, 5)},${round(pos.lon, 5)}?z=${this.mapContext.zoom}`,
|
||||
loadUrls: false,
|
||||
elevation: true
|
||||
});
|
||||
|
||||
if (now !== this.lastClick) {
|
||||
// There has been another click since the one we are reacting to.
|
||||
|
|
|
@ -153,7 +153,7 @@ async function _findOsmObject(type: string, id: string, loadElevation = false):
|
|||
async function _findLonLat(lonlatWithZoom: PointWithZoom, loadElevation = false): Promise<Array<SearchResult>> {
|
||||
const [body, elevation] = await Promise.all([
|
||||
request({
|
||||
url: `${nameFinderUrl}/reverse?format=json&addressdetails=1&polygon_geojson=1&extratags=1&namedetails=1&lat=${encodeURIComponent(lonlatWithZoom.lat)}&lon=${encodeURIComponent(lonlatWithZoom.lon)}&zoom=${encodeURIComponent(lonlatWithZoom.zoom != null ? (lonlatWithZoom.zoom >= 12 ? lonlatWithZoom.zoom+2 : lonlatWithZoom.zoom) : 17)}`,
|
||||
url: `${nameFinderUrl}/reverse?format=json&addressdetails=1&polygon_geojson=0&extratags=1&namedetails=1&lat=${encodeURIComponent(lonlatWithZoom.lat)}&lon=${encodeURIComponent(lonlatWithZoom.lon)}&zoom=${encodeURIComponent(lonlatWithZoom.zoom != null ? (lonlatWithZoom.zoom >= 12 ? lonlatWithZoom.zoom+2 : lonlatWithZoom.zoom) : 17)}`,
|
||||
json: true
|
||||
}),
|
||||
...(loadElevation ? [getElevationForPoint(lonlatWithZoom)] : [])
|
||||
|
|
Ładowanie…
Reference in New Issue