Android WebView从assets中加载html5页面,实现地理位置定位,有需要的朋友可以参考下。
今天调研一个html5页面的定位问题,发现在手机浏览器上html5是可以实现定位的,但是在webview中就无法定位了。而我居然以为html5的地理定位在webview中不可行。
html5页面内容如下:
代码语言:javascript
后来又在网上查了查,发现,需要设置一些东西。设置websetting的属性:
代码语言:javascript
//在Androidmanifest.xml中开启权限
代码语言:javascript
在某些限制应用定位权限的手机中,需要开启应用的定位权限,否则会定位失败
问题解决!
特别试了试:
同时打开网络和GPS可以定位,获得的是经纬度信息。
只打开网络可以定位,只打开GPS也可以定位。
关闭网络和GPS也可以定位。
由此可见,是由地理位置定位所得,只能获得经纬度信息。
若要获得详细的地址信息,需要调用地图API实现。