Geolocation is one of those Chromium features that uses the Google API. You must enable the Google Maps Geolocation API and billing, otherwise geolocation will not work.(地理位置是使用Google API的Chromium功能之一。您必须启用Google Maps Geolocation API和结算功能,否则地理定位将不起作用。)


Once you enable Google Maps Geolocation API and billing, you can provide the keys to the Chromium engine using one of the approaches described in the Chromium API Keys article.(启用Google Maps Geolocation API和计费功能后,您可以使用Chromium API密钥文章中介绍的方法之一将密钥提供给Chromium引擎。)


Note: due to the security restrictions in Chromium 50 and higher, geolocation doesn't work for file:/// URI. You must put a web page that works with the Geolocation API on a web server and access the web page through HTTPS protocol.(注意:由于Chromium 50和更高版本中的安全性限制,地理位置不适用于file:/// URI。您必须在Web服务器上放置一个与Geolocation API一起使用的网页,然后通过HTTPS协议访问该网页。)


Geolocation Permission(地理位置许可)

Please take into account that there is a specific permission that should be granted to enable geolocation in JxBrowser. (请考虑到应该授予特定的权限才能在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;
    }
});