在我的項目我顯示我的當前位置,顯示當前的經緯度long.But我不能 標記我目前在android中的位置。
Thnx提前。
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
Log.d(TAG, "onLocationChanged with location " + location.toString());
// Displays lat, long, altitude and bearing
String text = String.format("Lat:\t %f\nLong:\t %f\nAlt:\t %f\nBearing:\t %f", location.getLatitude(), location.getLongitude(), location.getAltitude(), location.getBearing());
this.locationText.setText(text);
try {
// This gets a list of addresses
List<Address> addresses = geocoder.getFromLocation(location.getLatitude(),
location.getLongitude(), 10);
for (Address address : addresses) {
this.locationText.append("\n" + "kaushik");
}
// Convert latitude and longitude into int that the GeoPoint constructor can understand
int latitude = (int)(location.getLatitude() * 1000000);
int longitude = (int)(location.getLongitude() * 1000000);
point = new GeoPoint(latitude,longitude);
mapController.animateTo(point);
mapController.setZoom(16);
MapOverlay mapOverLay=new MapOverlay();
mapOverLay.setPointToDraw(point);
List<Overlay> listOfOverlays=map.getOverlays();
listOfOverlays.clear();
listOfOverlays.add(mapOverLay);
map.invalidate();
} catch (IOException e) {
Log.e("LocateMe", "Could not get Geocoder data", e);
}
}
粘貼代碼,以便我們可以進行更改 – 2012-04-03 09:11:39
@Agarwal我已經啓動了我的項目。 – kaushikSuman 2012-04-03 09:13:46
更好,如果可以將你的sinppet粘貼在這裏將在未來使用完整給其他人 – 2012-04-03 09:19:45