8***@qq.com
8***@qq.com
  • 发布:2019-12-27 17:08
  • 更新:2019-12-27 17:08
  • 阅读:980

H5腾讯地图Android端定位,请问还需要什么相关配置吗?

分类:uni-app

项目在微信内webview和浏览器可以正常定位和显示位置,在Android端webView中不定位并且不显示位置,webView已经配置相关参数:

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webview = findViewById(R.id.mWeb);
WebSettings webSettings = webview.getSettings();
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
// 启用数据库
webSettings.setDatabaseEnabled(true);
String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
//启用地理定位
webSettings.setGeolocationEnabled(true);
// 设置定位的数据库路径
webSettings.setGeolocationDatabasePath(dir);
webSettings.setJavaScriptEnabled(true);
// 设置存储
webSettings.setDomStorageEnabled(true);
webSettings.setAppCacheMaxSize(1024 1024 8);
String appCachePath = getApplicationContext().getCacheDir().getAbsolutePath();
webSettings.setAppCachePath(appCachePath);
webSettings.setAllowFileAccess(true);
webSettings.setAppCacheEnabled(true);
webview.setWebChromeClient(mWebChromeClient);
webview.setWebViewClient(mWebView);
webview.loadUrl("xxxxxxx");
}

private WebChromeClient mWebChromeClient = new WebChromeClient() {
@Override
public void onGeolocationPermissionsShowPrompt(final String origin, final android.webkit.GeolocationPermissions.Callback callback) {
callback.invoke(origin, true, false);
super.onGeolocationPermissionsShowPrompt(origin, callback);
}
};

private WebViewClient mWebView = new WebViewClient() {  
    @Override  
    public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {  
        handler.proceed();  
    }  

    @Override  
    public boolean shouldOverrideUrlLoading(WebView view, String url) {  
        view.loadUrl(url);  
        return true;  
    }  

};
2019-12-27 17:08 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复