【发布时间】:2014-06-16 18:53:50
【问题描述】:
希望我的问题很清楚,鉴于我的代码中的以下示例,我有 3 个标记,因此有 3 个目的地,我已经包含了一个 URI,它打开了一个意图活动,它是谷歌地图应用程序并启动了有效的导航很好,除了已在 String uri 上手动输入纬度和经度坐标,单击时所有标记都会将我引导到相同的目的地,如何输入目的地变量以便获得单击的任何标记的坐标,我试过了“LatLong”而不是实际坐标,但这不起作用。
static final LatLng ARCADIA = new LatLng(-25.746318, 28.221322999999984);
static final LatLng HATFIELD = new LatLng(-25.7487333, 28.238043199999993);
static final LatLng CENTURION = new LatLng(-25.8602778, 28.189444399999957);
private GoogleMap map;
private Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_locate_store);
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
//map.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
map.setMyLocationEnabled(true);
map.animateCamera( CameraUpdateFactory.zoomTo( 5.0f ) );
Marker aracdia = map.addMarker(new MarkerOptions().position(ARCADIA).title("Arcadia")
.snippet("35 Hamilton Street\n Tel: 076 7533 123\n click-for-directions")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_small)));
Marker hatfield = map.addMarker(new MarkerOptions().position(HATFIELD).title("Hatfield").icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_small)));
Marker centurion = map.addMarker(new MarkerOptions().position(CENTURION).title("Centurion").icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_small)));
map.setOnInfoWindowClickListener(new OnInfoWindowClickListener(){
public void onInfoWindowClick(Marker marker){
String uri = String.format(Locale.ENGLISH, "http://maps.google.com/maps?daddr=%f,%f (%s)", -25.746318, 28.221322999999984, "Navigating...");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
【问题讨论】: