Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/206.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android开发从标记Lat和Long系统地设置目的地_Java_Android - Fatal编程技术网

Java Android开发从标记Lat和Long系统地设置目的地

Java Android开发从标记Lat和Long系统地设置目的地,java,android,Java,Android,希望我的问题是清楚的,在我的代码中给出了下面的示例,我有3个标记,因此有3个目的地,我包含了一个URI,它打开了一个intent活动,这是google maps应用程序,并启动导航,它工作正常,除了,lat和long坐标已在字符串uri上手动输入,单击时,所有标记将引导我到达同一目标,如何输入目标变量以便获得单击的任何标记的坐标,我尝试了“LatLong”而不是实际坐标,但这不起作用 static final LatLng ARCADIA = new LatLng(-25.746318,

希望我的问题是清楚的,在我的代码中给出了下面的示例,我有3个标记,因此有3个目的地,我包含了一个URI,它打开了一个intent活动,这是google maps应用程序,并启动导航,它工作正常,除了,lat和long坐标已在字符串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);
内部

mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener(){
                public void onInfoWindowClick(Marker marker){

// you determine which marker is clicked, maybe using the marker.getTitle();
//example: if marker.getTitle() is equals to Arcadia then set the latitude and longitude to arcadia lat and lng, 
//you can get the latitude of arcadia from marker position `aracdia.getPosition().latitude` or from the variable ARCADIA .. `ARCADIA.latitude`

//else if (another marker)..

//and finally set your uri and start activity
                        }
                });