2017-11-13 26 views
0

私のアプリケーションでMAPBOXを使用しています。現在のlatとlongを取得する方法はわかりません。この方法で現在の位置を取得しています。私の問題を解決するのを手伝ってください。MAPBOXでアンドロイドで現在の位置を取得する方法

 mapView = (MapView)view. findViewById(R.id.mapView); 
    mapView.setStyleUrl(Style.MAPBOX_STREETS); 
    mapView.onCreate(savedInstanceState); 

    //Add a mapBoxMap 
    mapView.getMapAsync(new OnMapReadyCallback() { 
     @Override 
     public void onMapReady(MapboxMap mapboxMap) { 
      mapboxMap.setMyLocationEnabled(true); 
      // Set the origin waypoint to the devices location 
      Position origin = Position.fromCoordinates(mapboxMap.getMyLocation().getLongitude(), mapboxMap.getMyLocation().getLatitude()); 

      Log.i("RR","mapboxMap.getMyLocation();"+origin); 
      // Log.i("RR","mapboxMap.getMyLocation();"+mapboxMap.getMyLocation().getLongitude()); 
      mapboxMap.getUiSettings().setZoomControlsEnabled(true); 
      mapboxMap.getUiSettings().setZoomGesturesEnabled(true); 
      mapboxMap.getUiSettings().setScrollGesturesEnabled(true); 
      mapboxMap.getUiSettings().setAllGesturesEnabled(true); 


     } 

    }); 

答えて

1

mapboxMap.setMyLocationEnabled(true);廃止されました。

あなたは緯度取得し、長い間この

locationEngine = new LostLocationEngine(MainActivity.this); 
    locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY); 
    locationEngine.setInterval(5000); 
    locationEngine.activate(); 
    Location lastLocation = locationEngine.getLastLocation(); 

のように(lastLocation.getLatitudeを使用するようにlocationEngineを使用する必要が

)、lastLocation.getLongitude()

関連する問題