()
| 147 | }); |
| 148 | |
| 149 | const useCurrentLocation = () => { |
| 150 | const availability = geoAvailability({ |
| 151 | hasGeolocation: Boolean(navigator.geolocation), |
| 152 | isSecureContext: window.isSecureContext, |
| 153 | hostname: window.location.hostname, |
| 154 | }); |
| 155 | if (!availability.ok) { |
| 156 | setGeoErr(availability.message); |
| 157 | return; |
| 158 | } |
| 159 | setGeoBusy(true); |
| 160 | setGeoErr(null); |
| 161 | navigator.geolocation.getCurrentPosition( |
| 162 | (pos) => { |
| 163 | set({ |
| 164 | centerLat: pos.coords.latitude, |
| 165 | centerLon: pos.coords.longitude, |
| 166 | locationName: "Current location", |
| 167 | }); |
| 168 | setGeoBusy(false); |
| 169 | }, |
| 170 | (err) => { |
| 171 | setGeoBusy(false); |
| 172 | const insecureContext = |
| 173 | !geoAvailability({ |
| 174 | hasGeolocation: true, |
| 175 | isSecureContext: window.isSecureContext, |
| 176 | hostname: window.location.hostname, |
| 177 | }).ok; |
| 178 | setGeoErr(geoErrorMessage(err.code, insecureContext)); |
| 179 | }, |
| 180 | { enableHighAccuracy: true, timeout: 15000, maximumAge: 60_000 }, |
| 181 | ); |
| 182 | }; |
| 183 | |
| 184 | // plane preview card |
| 185 | const planePreview = labelLines( |
nothing calls this directly
no test coverage detected