use of net.osmand.plus.GeocodingLookupService.AddressLookupRequest in project Osmand by osmandapp.
the class FavoriteAction method execute.
@Override
public void execute(final MapActivity activity) {
final LatLon latLon = activity.getMapView().getCurrentRotatedTileBox().getCenterLatLon();
final String title = getParams().get(KEY_NAME);
if (title == null || title.isEmpty()) {
progressDialog = createProgressDialog(activity, new DialogOnClickListener() {
@Override
public void skipOnClick() {
onClick(activity.getString(R.string.favorite), !Boolean.valueOf(getParams().get(KEY_DIALOG)));
}
@Override
public void enterNameOnClick() {
onClick("", false);
}
private void onClick(String title, boolean autoFill) {
activity.getMyApplication().getGeocodingLookupService().cancel(lookupRequest);
dismissProgressDialog();
addFavorite(activity, latLon, title, autoFill);
}
});
progressDialog.show();
lookupRequest = new AddressLookupRequest(latLon, new OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
dismissProgressDialog();
addFavorite(activity, latLon, address, !Boolean.valueOf(getParams().get(KEY_DIALOG)));
}
}, null);
activity.getMyApplication().getGeocodingLookupService().lookupAddress(lookupRequest);
} else {
addFavorite(activity, latLon, title, !Boolean.valueOf(getParams().get(KEY_DIALOG)));
}
}
use of net.osmand.plus.GeocodingLookupService.AddressLookupRequest in project Osmand by osmandapp.
the class MapMarkersListAdapter method lookupLocationAddress.
private void lookupLocationAddress(OsmandApplication app) {
LatLon loc = new LatLon(myLoc.getLatitude(), myLoc.getLongitude());
if (locRequest == null || !locRequest.getLatLon().equals(loc)) {
if (locRequest != null) {
app.getGeocodingLookupService().cancel(locRequest);
}
locRequest = new AddressLookupRequest(loc, new OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
locRequest = null;
locDescription.setName(address);
if (showLocationItem) {
notifyItemChanged(0);
}
}
}, null);
app.getGeocodingLookupService().lookupAddress(locRequest);
}
}
use of net.osmand.plus.GeocodingLookupService.AddressLookupRequest in project Osmand by osmandapp.
the class MapRouteInfoMenu method generateViaDescription.
public String generateViaDescription() {
TargetPointsHelper targets = getTargets();
List<TargetPoint> points = targets.getIntermediatePointsNavigation();
if (points.size() == 0) {
return "";
}
StringBuilder via = new StringBuilder();
for (int i = 0; i < points.size(); i++) {
if (i > 0) {
via.append(" ");
}
TargetPoint p = points.get(i);
String description = p.getOnlyName();
via.append(getRoutePointDescription(p.point, description));
boolean needAddress = new PointDescription(PointDescription.POINT_TYPE_LOCATION, description).isSearchingAddress(mapActivity) && !intermediateRequestsLatLon.contains(p.point);
if (needAddress) {
AddressLookupRequest lookupRequest = new AddressLookupRequest(p.point, new GeocodingLookupService.OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
updateMenu();
}
}, null);
intermediateRequestsLatLon.add(p.point);
geocodingLookupService.lookupAddress(lookupRequest);
}
}
return via.toString();
}
use of net.osmand.plus.GeocodingLookupService.AddressLookupRequest in project Osmand by osmandapp.
the class TargetPointsHelper method lookupAddressForIntermediatePoint.
private void lookupAddressForIntermediatePoint(final TargetPoint targetPoint) {
if (targetPoint != null && targetPoint.pointDescription.isSearchingAddress(ctx)) {
cancelPointAddressRequests(targetPoint.point);
AddressLookupRequest lookupRequest = new AddressLookupRequest(targetPoint.point, new GeocodingLookupService.OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
for (TargetPoint p : intermediatePoints) {
if (p.point.equals(targetPoint.point)) {
p.pointDescription.setName(address);
settings.updateIntermediatePoint(p.point.getLatitude(), p.point.getLongitude(), p.pointDescription);
updateRouteAndRefresh(false);
updateTargetPoint(p);
break;
}
}
}
}, null);
ctx.getGeocodingLookupService().lookupAddress(lookupRequest);
}
}
use of net.osmand.plus.GeocodingLookupService.AddressLookupRequest in project Osmand by osmandapp.
the class TargetPointsHelper method lookupAddressForPointToNavigate.
private void lookupAddressForPointToNavigate() {
if (pointToNavigate != null && pointToNavigate.isSearchingAddress(ctx) && (targetPointRequest == null || !targetPointRequest.getLatLon().equals(pointToNavigate.point))) {
cancelTargetPointAddressRequest();
targetPointRequest = new AddressLookupRequest(pointToNavigate.point, new GeocodingLookupService.OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
targetPointRequest = null;
if (pointToNavigate != null) {
pointToNavigate.pointDescription.setName(address);
settings.setPointToNavigate(pointToNavigate.point.getLatitude(), pointToNavigate.point.getLongitude(), pointToNavigate.pointDescription);
updateRouteAndRefresh(false);
updateTargetPoint(pointToNavigate);
}
}
}, null);
ctx.getGeocodingLookupService().lookupAddress(targetPointRequest);
}
}
Aggregations