Second...I've run into a problem
I'm trying to write an app that draws markers on the map each time your location changes. Using GPS of course.
Code as follows:
Using java Syntax Highlighting
- private Spinner radius;
- private MapView karta;
- private LinearLayout layout;
- private ZoomControls mZoom;
- private List<Overlay> mapOverlays;
- private Drawable icon;
- private Markers mapMarkers;
- private LocationManager GPSHandler;
- private Location myLocation;
- private LocationProvider locProvider;
- private LocationListener llistener;
- private MapController mc;
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
Listener class:
Using java Syntax Highlighting
- LocationListener llistener = new LocationListener() {
- @Override
- public void onStatusChanged(String provider, int status, Bundle extras) {
- // TODO Auto-generated method stub
- //Toast.makeText(getBaseContext(), status, Toast.LENGTH_SHORT).show();
- }
- @Override
- public void onProviderEnabled(String provider) {
- // TODO Auto-generated method stub
- }
- @Override
- public void onProviderDisabled(String provider) {
- // TODO Auto-generated method stub
- }
- @Override
- public void onLocationChanged(Location location) {
- // TODO Auto-generated method stub
- Toast.makeText(getBaseContext(), "Location changed", Toast.LENGTH_SHORT).show();
- if (location != null) {
- GeoPoint p = new GeoPoint(
- (int) (location.getLatitude() * 1E6),
- (int) (location.getLongitude() * 1E6));
- mc.animateTo(p);
- mc.setZoom(16);
- OverlayItem item = new OverlayItem(p,"","");
- mapMarkers.addOverlay(item);
- mapMarkers.setFocus(item);
- mapOverlays.add(mapMarkers);
- //karta.invalidate();
- }
- }
- };
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
Settting up GPS:
Using java Syntax Highlighting
- karta = (MapView) findViewById(R.id.mapview);
- mc = karta.getController();
- karta.setBuiltInZoomControls(true);
- mapOverlays = karta.getOverlays();
- icon = this.getResources().getDrawable(R.drawable.arrow);
- mapMarkers = new Markers(icon);
- GPSHandler = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
- GPSHandler.requestLocationUpdates(GPSHandler.GPS_PROVIDER, MINIMUM_TIME_BETWEEN_UPDATE, MINIMUM_DISTANCECHANGE_FOR_UPDATE, llistener);
Parsed in 0.035 seconds, using GeSHi 1.0.8.4
I'm querying last known location as well and it's returning one. The onLocationChanged fires only once at the start and then not anymore (I'm loading a GPX file in the DDMS view). Any idea what I'm doing wrong?
Thanks for all the help.

