即时开发具有多个地图和方向的Android应用程序,用户可以选择地图中的哪些车辆并显示方向。
我与每个标记(不是信息窗口)的听众混淆,我想用户选择标记和自动路线方向到当前位置。我已经完成了路线和多个标记,但我不能改变每辆车的路线。它总是以最后一排汽车结束,这里是我的阵列标记:
@Override
public void onMapReady(GoogleMap googleMap)
{
LatLng[] point_new = new LatLng[3];
point_new[0] = new LatLng(-7.7827567,110.364876);
point_new[1] = new LatLng(-7.8061627,110.3859053);
point_new[2] = new LatLng(-7.7872971, 110.3858244);
for (int i = 0; i < point_new.length; i++) {
mGoogleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mGoogleMap.addMarker(new MarkerOptions()
.position(point_new[i])
.title("Cars")
.snippet("Type:Economic")
.icon((BitmapDescriptorFactory.fromResource(R.drawable.cars)))
);
sessionManager = new SessionManager(getApplicationContext());
sessionManager.createSession(point_new[i].toString());
MapLocationActivity.this.setSomeDestinasi(point_new[i]);
mGoogleMap.moveCamera(CameraUpdateFactory.newLatLng(point_new[i]));
}
}
和我的onclick标记代码:
@Override
public boolean onMarkerClick(final Marker marker) {
if (marker.equals(mGoogleMap))
{
//handle click here
requestDirection();
sessionManager = new SessionManager(getApplicationContext());
HashMap<String, String> user = sessionManager.getUserDetails();
String carslocation = user.get(SessionManager.key_latlon);
AlertDialog alertDialog = new AlertDialog.Builder(MapLocationActivity.this).create();
alertDialog.setTitle("Alert");
alertDialog.setMessage(carslocation);
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertDialog.show();
}
return true;
}
我使用sharedpreference存储lat和long的动态路由,问题是我如何点击标记[i]?
if (marker.equals(marker[i]))
{
}
marker+i = mGoogleMap.addMarker(new MarkerOptions()
);
注意:我使用akexorcist谷歌方向库
感谢