forked from MapComplete/MapComplete
		
	Only jump to the start location if no coordinates are given in the URL
This commit is contained in:
		
							parent
							
								
									90f69bdd93
								
							
						
					
					
						commit
						a3f704a57d
					
				
					 2 changed files with 8 additions and 1 deletions
				
			
		|  | @ -1,5 +1,6 @@ | ||||||
| import { UIEventSource } from "../UIEventSource" | import { UIEventSource } from "../UIEventSource" | ||||||
| import { LocalStorageSource } from "../Web/LocalStorageSource" | import { LocalStorageSource } from "../Web/LocalStorageSource" | ||||||
|  | import { QueryParameters } from "../Web/QueryParameters" | ||||||
| 
 | 
 | ||||||
| type GeolocationState = "prompt" | "requested" | "granted" | "denied" | type GeolocationState = "prompt" | "requested" | "granted" | "denied" | ||||||
| 
 | 
 | ||||||
|  | @ -79,6 +80,11 @@ export class GeoLocationState { | ||||||
|             // We set the flag to false again. If the user only wanted to share their location once, we are not gonna keep bothering them
 |             // We set the flag to false again. If the user only wanted to share their location once, we are not gonna keep bothering them
 | ||||||
|             this._previousLocationGrant.setData("false") |             this._previousLocationGrant.setData("false") | ||||||
|             console.log("Requesting access to GPS as this was previously granted") |             console.log("Requesting access to GPS as this was previously granted") | ||||||
|  |             const latLonGivenViaUrl = | ||||||
|  |                 QueryParameters.wasInitialized("lat") || QueryParameters.wasInitialized("lon") | ||||||
|  |             if (!latLonGivenViaUrl) { | ||||||
|  |                 this.requestMoment.setData(new Date()) | ||||||
|  |             } | ||||||
|             this.requestPermission() |             this.requestPermission() | ||||||
|         } |         } | ||||||
|         window["geolocation_state"] = this |         window["geolocation_state"] = this | ||||||
|  | @ -120,7 +126,7 @@ export class GeoLocationState { | ||||||
|             // Hence that we continue the flow if it is "requested"
 |             // Hence that we continue the flow if it is "requested"
 | ||||||
|             return |             return | ||||||
|         } |         } | ||||||
|         this.requestMoment.setData(new Date()) | 
 | ||||||
|         this.permission.setData("requested") |         this.permission.setData("requested") | ||||||
|         try { |         try { | ||||||
|             navigator?.permissions |             navigator?.permissions | ||||||
|  |  | ||||||
|  | @ -91,6 +91,7 @@ export class GeolocationControl extends VariableUiElement { | ||||||
|                 geolocationState.currentGPSLocation.data === undefined |                 geolocationState.currentGPSLocation.data === undefined | ||||||
|             ) { |             ) { | ||||||
|                 lastClick.setData(new Date()) |                 lastClick.setData(new Date()) | ||||||
|  |                 geolocationState.requestMoment.setData(new Date()) | ||||||
|                 await geolocationState.requestPermission() |                 await geolocationState.requestPermission() | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue