如何在追踪gps的同时不断更新地图?
单击按钮时,getmap()正在调用。
public void getMap() {
//if (a != 101.717026 || b!= 3.002034) {
Toast.makeText(TestdbActivity.this,newaddress, Toast.LENGTH_LONG).show();
Intent i = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://http://maps.google.com.my/maps?f=d&source=s_d&saddr="+newaddress+"&daddr="+params1+""));
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
& Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
i.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(i);
}updategps函数:
public void onLocationChanged(Location location) {
a = location.getLongitude();
b = location.getLatitude();
String message = String.format("New Location \n Longitude: %1$s \n Latitude: %2$s", a, b);
Toast.makeText(TestdbActivity.this, message, Toast.LENGTH_LONG).show();
newaddress = b+","+ a;
return;
}
public void onStatusChanged(String s, int i, Bundle b) {
Toast.makeText(TestdbActivity.this, "Provider status changed",Toast.LENGTH_LONG).show();
}
public void onProviderDisabled(String s) {
Toast.makeText(TestdbActivity.this,"Provider disabled by the user. GPS turned off",Toast.LENGTH_LONG).show();
}
public void onProviderEnabled(String s) {
Toast.makeText(TestdbActivity.this,"Provider enabled by the user. GPS turned on", Toast.LENGTH_LONG).show();
}我能做一个while循环吗?如果使用while循环?
发布于 2011-12-15 00:57:00
如果您希望地图更新,那么显示地图的正常解决方案是在您自己的活动中放置一个mapView,而不是让您的活动启动地图应用程序。你这样做有很好的理由吗?按照你现在的方式来做,当然,一旦你启动了MapsActivity,你的应用程序就会向下移动到活动堆栈中,这样你就会放松控制。
注册到位置管理器后,系统会定期调用onLocationChanged,因此您只需更新其中的地图即可。当然,在您自己的活动中使用mapView,您可以将其设置为自动。
Here是关于maps的页面。this是从上面引用的教程。
https://stackoverflow.com/questions/8507825
复制相似问题