我有一个小问题......我制作了一个扩展 webview 的 Android 应用程序。带有这样地图的 webview Html 页面:地图示例,也是在这里我得到了灵感。我的 onCreate 方法如下所示:
super.onCreate(savedInstanceState);
//Removes the title bar in the application
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
//Creation of the Webview found in the XML Layout file
browserView = (WebView)findViewById(R.id.webkit);
//Removes both vertical and horizontal scroll bars
browserView.setVerticalScrollBarEnabled(false);
browserView.setHorizontalScrollBarEnabled(false);
myLocationManager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
//Enable Javascripts
url = "http://www.my-homepage.dk/map_example.html";
browserView.getSettings().setJavaScriptEnabled(true);
//The website which is wrapped to the webview
browserView.loadUrl(url);
因此,当我的应用程序获取 GPS 位置时,它会调用此方法:
LocationListener onLocationChange=new LocationListener() {
public void onLocationChanged(Location location) {
StringBuilder buf=new StringBuilder(url);
buf.append("?");
buf.append("lon=");
buf.append(String.valueOf(location.getLongitude()));
buf.append("&");
buf.append("lat=");
buf.append(String.valueOf(location.getLatitude()));
browserView.loadUrl(buf.toString());
}
所以它基本上只是加载另一个 URL.... 但是,我的问题是,1. 它保留原始网站“地图图像”,我想它会“卸载”页面,以及 2. 当第二个 url 加载时,它它需要很长时间才能完成,当我在我的 HTC Desire 上进行测试时,它有时在关闭屏幕并锁定之前不显示第二个加载页面(带有位置的地图),或者如果我出去和进来该应用程序,有时也有帮助...
希望你能帮忙:)