Note that there are some explanatory texts on larger screens.

plurals
  1. POfind out current position in OSMdroid
    primarykey
    data
    text
    <p>I want to find map of my current position and update it when i move via showing a icon in OSMdroid.I find no problem when give specific location latitude and longitude and drawing icon but there are two errors when i give current location latitude and longitude.</p> <pre><code>public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mResourceProxy = new DefaultResourceProxyImpl(getApplicationContext()); setContentView(R.layout.main); mMapView = (MapView) this.findViewById(R.id.mapview); mMapView.setTileSource(TileSourceFactory.MAPNIK); mMapView.setBuiltInZoomControls(true); mMapView.setMultiTouchControls(true); mapController = this.mMapView.getController(); mapController.setZoom(15); Criteria criteria = new Criteria(); criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAltitudeRequired(false); criteria.setBearingRequired(false); criteria.setCostAllowed(true); criteria.setPowerRequirement(Criteria.POWER_LOW); String provider = mLocMgr.getBestProvider(criteria, true); Location location = mLocMgr.getLastKnownLocation(provider); GeoPoint mypoint = new GeoPoint(location.getLatitude(), location.getLongitude()); // centre map here GeoPoint mypointicon = new GeoPoint(location.getLatitude()+1000, location.getLongitude()+1000); // icon goes here mapController.setCenter(mypoint); mLocMgr = (LocationManager) getSystemService(LOCATION_SERVICE); mLocMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 100, this); ArrayList&lt;OverlayItem&gt; items=new ArrayList&lt;OverlayItem&gt;(); items.add(new OverlayItem("Here", "Sample Description", mypointicon)); this.mMyLocationOverlay = new ItemizedIconOverlay&lt;OverlayItem&gt;(items, new ItemizedIconOverlay.OnItemGestureListener&lt;OverlayItem&gt;() { @Override public boolean onItemSingleTapUp(final int index, final OverlayItem item) { Toast.makeText( MapOverLayGiveActivity.this, "Item '" + item.mTitle, Toast.LENGTH_LONG).show(); return true; // We 'handled' this event. } @Override public boolean onItemLongPress(final int index, final OverlayItem item) { Toast.makeText( MapOverLayGiveActivity.this, "Item '" + item.mTitle ,Toast.LENGTH_LONG).show(); return false; } }, mResourceProxy); this.mMapView.getOverlays().add(this.mMyLocationOverlay); mMapView.invalidate(); } </code></pre> <p>Error: java.lang.NullPointerException<br> java.lang.RunTimeException</p> <p>What's wrong in my code and how can i do that? thanks...</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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