[英]How can i get the user current location and put marker on it in android by using google maps
i develop the application that has Google API so i can put map in my app i have problem in get user Current location, i want : when the user open map Activity it display the map and marker on her location.i already doing google API stuff but i faced problem with USER CURRENT LOCATION AND MARKER ON IT. 我开发了具有Google API的应用程序,因此我可以在我的应用程序中放置地图。我在获取用户当前位置时遇到问题,我要:当用户打开地图活动时,它会在她的location.i上显示地图和标记。但是我在用户当前位置和标记上遇到了问题。 this is my code(it is shows me in ocean !!): alert.setButton2("get an address", new DialogInterface.OnClickListener() {
这是我的代码(向我展示了海洋!!):alert.setButton2(“获取地址”,新的DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,
int which) {
// TODO Auto-generated method stub
Geocoder geocoder = new Geocoder(
getBaseContext(), Locale.getDefault());
try {
List<Address> address = geocoder.getFromLocation(touchedPoint.getLatitudeE6() / 1E6,touchedPoint.getLatitudeE6() / 1E6,1);
OverlayItem overlayItem = new OverlayItem( touchedPoint, "Whats up", "2nd String");
CustomPinpoint custom = new CustomPinpoint(d,MapsActivity.this);
custom.insertPinpoint(overlayItem);
overlaylist.add(custom);
if (address.size() > 0) {
String display = "";
for (int i = 0; i < address.get(0)
.getMaxAddressLineIndex(); i++) {
display += address.get(0)
.getAddressLine(i) + "\n";
}
Toast t = Toast.makeText(
getBaseContext(), display,
Toast.LENGTH_LONG);
t.show();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
}
}
});
i Have a nightmare about Map, PLEASE FIX MY CODE 我对地图有噩梦,请修正我的代码
please check below example 请检查以下示例
1) http://eagle.phys.utk.edu/guidry/android/mapOverlayDemo.html 1) http://eagle.phys.utk.edu/guidry/android/mapOverlayDemo.html
2) http://androidmyway.wordpress.com/2012/02/26/map-marker-dragging 2) http://androidmyway.wordpress.com/2012/02/26/map-marker-dragging
in second one you can check how to get address. 在第二个中,您可以检查如何获取地址。
Thank You 谢谢
if you just want to show users current location you could use MyLocationOverlay class in mapactivity. 如果您只想向用户显示当前位置,则可以在mapactivity中使用MyLocationOverlay类。 it will draw the marker on the location itself.
它将在位置本身上绘制标记。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.