Geolocation is one of those Chromium features that uses Google API. You must enable Google Maps Geolocation API and billing, otherwise Geolocation API will not work.


Once you enable Google Maps Geolocation API and billing, you can provide the keys to JxBrowser Chromium engine using one of the approaches described in the Chromium API Keys article.


Geolocation Permission

Please take into account that there is a specific permission that should be granted to enable geolocation in JxBrowser. 

The following sample code demonstrates how to enable this permission:


browser.setPermissionHandler(new PermissionHandler() {
    @Override
    public PermissionStatus onRequestPermission(PermissionRequest request) {
        if (request.getPermissionType() == PermissionType.GEOLOCATION) {
            return PermissionStatus.GRANTED;
        }
        return PermissionStatus.DENIED;
    }
});