You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.5 KiB
54 lines
1.5 KiB
package org.r3pek.pharmacies;
|
|
|
|
import org.r3pek.pharmacies.utils.GlobalVars;
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
import android.location.Location;
|
|
import android.location.LocationManager;
|
|
import android.os.Handler;
|
|
|
|
import com.google.android.maps.GeoPoint;
|
|
import com.google.android.maps.ItemizedOverlay;
|
|
import com.google.android.maps.MapView;
|
|
import com.google.android.maps.OverlayItem;
|
|
|
|
public class GetPositionOverlay extends ItemizedOverlay<OverlayItem> {
|
|
private PharmaciesOverlay pharmacies;
|
|
private MyPositionOverlay myLocation;
|
|
private Handler onSelectionHandler;
|
|
|
|
public GetPositionOverlay(Drawable defaultMarker, PharmaciesOverlay pharmacies, MyPositionOverlay myLocation, Handler onSelectionHandler) {
|
|
super(defaultMarker);
|
|
this.pharmacies = pharmacies;
|
|
this.myLocation = myLocation;
|
|
this.onSelectionHandler = onSelectionHandler;
|
|
populate();
|
|
}
|
|
|
|
@Override
|
|
protected OverlayItem createItem(int i) {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public int size() {
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public boolean onTap(GeoPoint p, MapView map) {
|
|
Location l = new Location(LocationManager.GPS_PROVIDER);
|
|
l.setLatitude(p.getLatitudeE6()/1000000.0);
|
|
l.setLongitude(p.getLongitudeE6()/1000000.0);
|
|
l.setAccuracy(0.0f);
|
|
GlobalVars.getPharmacies().clear();
|
|
pharmacies.refresh();
|
|
onSelectionHandler.sendEmptyMessage(0);
|
|
GlobalVars.positioner.setFixedLocation(l);
|
|
map.getOverlays().clear();
|
|
map.getOverlays().add(pharmacies);
|
|
map.getOverlays().add(myLocation);
|
|
map.postInvalidate();
|
|
return super.onTap(p, map);
|
|
}
|
|
}
|
|
|