Note that there are some explanatory texts on larger screens.

plurals
  1. POCurrent Loation is not picking in android
    text
    copied!<p>I am now moving with a project related to Google Map service. I would like to point out my current location in my map. For that, I have got an idea of using itemizedoverlay. I retrieve the current location by the help of Geopoint. But when I'm used the itemizedoverlay in my code, the location cannot be picked up and I am using this in my OnCreate method. If I am moving this to OnLocationChanged method, then GeoPoint(point) will not be picked up by the itemizedoverlay and will end with an error and in the present condition, the app gets crushed down. </p> <pre><code> MapView mapView; Location location; LocationManager locationmanager; LocationListener locationlistener; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mapView = (MapView) findViewById(R.id.mapView); mapView.setTraffic(true); mapView.setBuiltInZoomControls(true); //locationmanager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); // locationlistener = new GPSLocationListener(); // locationmanager.requestLocationUpdates(LocationManager.GPS_PROVIDER 0,0,locationlistener); GeoPoint point = new GeoPoint( (int) (location.getLatitude() * 1E6), (int) (location.getLongitude() * 1E6)); Toast.makeText(getBaseContext(), "Latitude: " + location.getLatitude() + " Longitude: " + location.getLongitude(), Toast.LENGTH_SHORT).show(); List&lt;Overlay&gt; mapOverlays = mapView.getOverlays(); Drawable drawable = this.getResources().getDrawable(R.drawable.icon); HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable,this); OverlayItem overlayitem = new OverlayItem(point,"","" ); itemizedoverlay.addOverlay(overlayitem); mapOverlays.add(itemizedoverlay); } /* private class GPSLocationListener implements LocationListener { @Override public void onLocationChanged(Location location) { if (location != null) { GeoPoint point = new GeoPoint( (int) (location.getLatitude() * 1E6), (int) (location.getLongitude() * 1E6)); Toast.makeText(getBaseContext(), "Latitude: " + location.getLatitude() + " Longitude: " + location.getLongitude(), Toast.LENGTH_SHORT).show(); OverlayItem overlayitem = new OverlayItem(point,"","" ); itemizedoverlay.addOverlay(overlayitem); mapOverlays.add(itemizedoverlay); } } */ @Override protected boolean isRouteDisplayed() { // TODO Auto-generated method stub return false; } @Override public void onLocationChanged(Location location) { // TODO Auto-generated method stub } @Override public void onProviderDisabled(String provider) { Toast.makeText(getBaseContext(),"GPS Disabled",Toast.LENGTH_SHORT).show(); } @Override public void onProviderEnabled(String provider) { Toast.makeText(getBaseContext(),"GPS Enabled",Toast.LENGTH_SHORT).show(); } @Override public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub } </code></pre> <p>Can you please suggest me a solution for this?? Thanks In Advance and sorry if I made any mistakes here.</p>
 

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