【发布时间】:2016-04-04 23:52:43
【问题描述】:
我是安卓世界的新人。试图从谷歌地图获取当前坐标。我已经完成了一个示例应用程序,它以意图方式打开谷歌地图(来自 android 网站)。我想做的是从那个意图中得到 lat-lng。到目前为止我已经完成了-
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
// mMap = googleMap;
Uri uri = Uri.parse("geo:latitude,longitude?z=17");
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri);
startActivity(intent);
}
}
更新: 我知道我可以在android中获得当前坐标。 但我想从谷歌地图意图中获取坐标(当前显示标记位置)?
【问题讨论】:
-
从起始意图获取 lat-lng 是什么意思.. 你想将 lat 和 long 设置为起始意图还是什么?
-
@bharat - 我已经更新了我的问题。
-
我不认为您可以将 Google 地图应用程序标记/s 详细信息添加到您的应用程序中......
标签: android google-maps-android-api-2