How to enable geolocation?

Support for the JavaScript Geolocation API varies by 3D WebView package. Please see the following sections for a description of each package's geolocation support:

3D WebView for Windows and macOS

3D WebView for Windows and macOS embeds Chromium using Chromium Embedded Framework (CEF). Unfortunately, CEF doesn't currently support the JavaScript Geolocation API. I'm tracking this issue and will update this article if this changes in the future.

3D WebView for Android

For 3D WebView for Android, please see the documentation for AndroidWebView.SetGeolocationEnabled() for instructions for enabling geolocation.

3D WebView for Android with Gecko Engine

For 3D WebView for Android with Gecko Engine, please see the documentation for AndroidGeckoWebView.SetGeolocationEnabled() for instructions for enabling geolocation.

3D WebView for iOS

For 3D WebView for iOS, you can enable the JavaScript Geolocation API by adding a value for "Location Usage Description" in iOS Player Settings -> Other Settings:

iOS location usage description

Then when the web page uses the JavaScript Geolocation API at runtime, iOS displays a permission prompt to the user.

3D WebView for UWP / Hololens

For 3D WebView for UWP / Hololens, please see the documentation for UwpWebView.SetGeolocationEnabled() for instructions for enabling geolocation.

2D WebView for WebGL

For 2D WebView for WebGL, you can enable geolocation with WebGLWebView.SetGeolocationEnabled().