Tue, 08/16/2016 - 00:43
#1
Follow user location in Android SDK
Hi,
I used example code to follow user location
private void enableUserTracking(MapView mapView) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mapView.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
}
But i get a error about visibility off method : setMyLocationTrackingMode not public, not found.
In android sdk, how i follow user location?
Thanks
Hi,
I'm also getting errors on the Use the User's Location Example. I copied the example verbatim:
package com.vmcomlab.myfirstmapquestapp; //my app name
import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import com.mapbox.mapboxsdk.constants.MyLocationTracking;
import com.mapquest.mapping.maps.MapView;
//import com.mapquest.mapping.view.MapView;
public class MainActivity extends Activity {
private MapView mMapView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mMapView = (MapView) findViewById(R.id.mapquestMapView);
enableUserTracking(mMapView);
mMapView.onCreate(savedInstanceState);
}
private void enableUserTracking(MapView mapView) {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mapView.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
}
}
thanks,
Roy
'setMyLocationTrackingMode(int)' is not public in 'com.mapbox.mapboxsdk.maps.MapView'. Cannot be accessed from outside package
also complaining that view in in the following statement cannot be resolved:
import com.mapquest.mapping.view.MapView;
I changed it to:
import com.mapquest.mapping.maps.MapView;
not sure if that's correct.
Y haven't you updated the code yet? It's been almost 4 months now. So what's the alternative can u plzz tell me asap?
Hi MQBrianCoakley ,
I am still facing the same issue. Can you let me know where can I find the updated code?
mMapboxMap.setMyLocationEnabled(true); seems to do the stuff
the alternative you suggested isn't working....
The code you posted only allow to enable current location with blue dot. BUT what about the current lat/lng. As I need current lat/lng (like OnLocationChanged).
Has anyone solved the issue? I am still facing the same issue.
Im having the same issue her tying to get current latlng with map sdk. Has anyone fixed it yet?