我想创建一个地图活动(FragmentActivity)来显示Google地图并显示2点之间的导航。
我有一个显示一个位置,但我不知道如何创建导航到另一个点,我看到的每个链接都给他们的web api作为解决方案(https://maps.google.com/maps?saddr=X,Y&daddr=X,Y)
我希望通过活动以编程方式完成它所做的工作而不只是链接到他们的网页
到目前为止我的代码:
try{
bndl = getIntent().getExtras();
COORDS = new LatLng(bndl.getDouble("lat"), bndl.getDouble("long"));
if (map == null) {
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
if (map != null) {
map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
map.addMarker(new MarkerOptions().position(COORDS).title("Your parking spot!"));
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(COORDS)
.zoom(20)
.bearing(90)
.tilt(0)
.build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
}
}
catch (Exception e){
Log.v("except", ""+e);
}
现在这仅显示一个位置(应该如此)但是如何创建另一个标记或某些东西来导航到?有没有办法做到这一点,还是我必须使用他们的网络API?
答案 0 :(得分:2)