Cannot get the Initial tutorial for OSM droid to display my current location..

54 views
Skip to first unread message

Alan Holmes

unread,
Nov 22, 2017, 8:04:34 AM11/22/17
to osmdroid
Hey I have follow the whole getting started tutorial on the OSMdroid git hub account...
I cannot get the current location on the map 
Anyone have any help for me on this???

JAVA

@Override public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);


Context ctx = getApplicationContext();
//important! set your user agent to prevent getting banned from the osm servers
Configuration.getInstance().load(ctx, PreferenceManager.getDefaultSharedPreferences(ctx));
setContentView(R.layout.activity_map);

mMapView = (MapView) findViewById(R.id.mapview);
mMapView.setTileSource(TileSourceFactory.MAPNIK);

mMapView.setBuiltInZoomControls(true);
mMapView.setMultiTouchControls(true);

IMapController mapController = mMapView.getController();
mapController.setZoom(9);
GeoPoint startPoint = new GeoPoint(52.1237453, 6.9293683);
mapController.setCenter(startPoint);

this.mLocationOverlay = new MyLocationNewOverlay(new GpsMyLocationProvider(ctx),mMapView);
this.mLocationOverlay.enableMyLocation();
mMapView.getOverlays().add(this.mLocationOverlay);


XML Code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<org.osmdroid.views.MapView
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"
tilesource="Mapnik" />


</LinearLayout>

Alex O'Ree

unread,
Dec 15, 2017, 6:26:55 PM12/15/17
to osmdroid
that's all that's needed. And manifest permissions....and runtime permissions...and gps hardware + being outdoors
Reply all
Reply to author
Forward
0 new messages