如果只显示地图
val webView: WebView = findViewById(R.id.webView)
webView.settings.javaScriptEnabled = true
webView.loadUrl("https://test.cn")//h5地址
如果需要定位,则需要加以下代码,否则不弹窗
webView.webChromeClient = object : WebChromeClient() {
override fun onReceivedIcon(view: WebView?, icon: Bitmap?) {
super.onReceivedIcon(view, icon)
}
}
另外还需要权限
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
以及手机应用权限开启