Note that there are some explanatory texts on larger screens.

plurals
  1. POOSMDroid GPS tracking and overlaying the track
    primarykey
    data
    text
    <p>I'm making a GPS tracking application with osmdroid map. I have a service which tracks gps data and stores the it in a sqlite databse. The service communicates with the map with a broadcast (every time the location is changed it casts a broadcast message). When the Map gets the broadcast message it gets the latest latitude and longitude from the database and moves the map to the geopoint. So far it works fluently. </p> <p>Now, I want to overlay the map with the current track, showing the route on it. I tired it with ItemizedIconOverlay this way:</p> <pre><code>public static void locateMap(Context context) { try{ SQLiteDatabase database = context.openOrCreateDatabase(DBNAME, MODE_PRIVATE, null); Cursor cLat = database.rawQuery(latitudeQuery, null); if (cLat.moveToFirst()) { latitude = cLat.getDouble(0); } else { latitude = 0; } Cursor cLong = database.rawQuery(longitudeQuery, null); if (cLong.moveToFirst()) { longitude = cLong.getDouble(0); } else { longitude = 0; } database.close(); GeoPoint geoPoint = new GeoPoint(latitude,longitude); mMapController.animateTo(geoPoint); mMapController.setCenter(geoPoint); overlayItems.add(new OverlayItem("","",geoPoint)); Drawable mDrawable = context.getResources().getDrawable(R.drawable.pont); mResourceProxy = new DefaultResourceProxyImpl(context.getApplicationContext()); mMyLocationOverlay = new ItemizedIconOverlay&lt;OverlayItem&gt;(overlayItems, mDrawable, null, mResourceProxy); mMapView.getOverlays().add(mMyLocationOverlay); } catch(Exception ex){ String err = (ex.getMessage()==null)?"drawOnMapFailed":ex.getMessage(); Log.v("MAP",err); } } </code></pre> <p>And it works until a click on the map. I get IndexOutOfBoundsException excepion, so i figured the map doesn't really like it this way. Is there something wrong with the code, or is there any other way to overlay osmdroid? Maybe it's something with the way i'm making this application?</p> <p>UPDATE: i tried with PathOverlay this way, didn't show anything on the map:</p> <pre><code> PathOverlay mMyLocationOverlay = new PathOverlay(Color.RED, context); mMyLocationOverlay.addPoint(geoPoint); mMapView.getOverlays().add(mMyLocationOverlay); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload