Question

I have the following functionality working in my app.

  1. I Use MyLocationOverlay to get my current location.
  2. I extended MyLocationOverlay in order to be able to drop a custom marker instead of the blinking blue marker.

I need help on the last requirement. I simply want a marker to stay fixed on the location that MyLocationOverlay says it found originally and not move around as it jumps from satellite to satellite.

What are my options for creating this type of user experience?

Was it helpful?

Solution

I would recommend saving off the first geopoint that gets fed into the drawMyLocation function inside the CustomLocationOverlay and using that instead of the myLocation fed to the function.

 int intFirstGeoPoint = 0;
 GeoPoint FirstGeoPoint;

protected void drawMyLocation(Canvas canvas, MapView mapView, Location lastFix, GeoPoint myLocation, long when) {

        if(intFirstGeoPoint == 0){
             FirstGeoPoint=myLocation;
             intFirstGeoPoint=1;
        }else{
             myLocation=FirstGeoPoint;
        }

        // translate the GeoPoint to screen pixels
        Point screenPts = mapView.getProjection().toPixels(myLocation, null);
        ...
        ...

You could also capture this location and create a new DrawableMapOverlay that only draws this point instead of hijacking the LocationOverlay

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top