WebSettings settings=webview.getSettings();
webview.loadUrl("file:///android_asset/location.htm");
String dir=this.getDir("database", Context.MODE_PRIVATE).getPath();//加载地图的数据库路径(必须有)
settings.setJavaScriptEnabled(true);//允许js
settings.setBuiltInZoomControls(true);
settings.setDatabaseEnabled(true);//允许加载到数据库
settings.setGeolocationEnabled(true);//允许加载地图
settings.setGeolocationDatabasePath(dir);//设置加载的路径
settings.setDomStorageEnabled(true);
//设置权限(必须有)
webview.setWebChromeClient(new WebChromeClient(){
@Override
public void onGeolocationPermissionsShowPrompt(String origin,
Callback callback) {
callback.invoke(origin, true, false);
super.onGeolocationPermissionsShowPrompt(origin, callback);
}
});