views:

37

answers:

1

I am trying to make it so a MapView zooms to a current location based on a GeoPoint. I am setting the location using the geo fix command in telnet. My problem is that when I first input a location using geo fix my code will correctly navigate to a location on the map. If I try to set another location using geo fix however it does not update. Here is the code to update:

public void updateLocation(Location loc) {
    p = new GeoPoint((int)(loc.getLongitude() * 1E6),(int)(loc.getLatitude() * 1E6));

    mc = mapView.getController();

    mc.animateTo(p);
}

and here is my code to call the update:

LocationListener onLocationChange=new LocationListener() {
    public void onLocationChanged(Location location) {
        updateLocation(location);
    }

etc...

I have the following in onResume():

    super.onResume();
    myLocationManager.requestLocationUpdates("gps", 0, 200, onLocationChange);

The points I am trying to geo fix to are far enough apart to meet the minimum distance requirement. Anyone have any ideas of what I'm missing?

A: 

Assuming your MapActivity implements LocationListener, then change

myLocationManager.requestLocationUpdates("gps", 0, 200, onLocationChange);

to

myLocationManager.requestLocationUpdates("gps", 0, 200, this);

'this' holds the location listener

NickT