Search in sources :

Example 6 with AddressLookupRequest

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)));
    }
}
Also used : LatLon(net.osmand.data.LatLon) OnAddressLookupResult(net.osmand.plus.GeocodingLookupService.OnAddressLookupResult) AddressLookupRequest(net.osmand.plus.GeocodingLookupService.AddressLookupRequest)

Example 7 with AddressLookupRequest

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);
    }
}
Also used : LatLon(net.osmand.data.LatLon) OnAddressLookupResult(net.osmand.plus.GeocodingLookupService.OnAddressLookupResult) AddressLookupRequest(net.osmand.plus.GeocodingLookupService.AddressLookupRequest)

Example 8 with AddressLookupRequest

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();
}
Also used : GeocodingLookupService(net.osmand.plus.GeocodingLookupService) PointDescription(net.osmand.data.PointDescription) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) TargetPointsHelper(net.osmand.plus.TargetPointsHelper) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) AddressLookupRequest(net.osmand.plus.GeocodingLookupService.AddressLookupRequest)

Example 9 with AddressLookupRequest

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);
    }
}
Also used : AddressLookupRequest(net.osmand.plus.GeocodingLookupService.AddressLookupRequest)

Example 10 with AddressLookupRequest

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);
    }
}
Also used : AddressLookupRequest(net.osmand.plus.GeocodingLookupService.AddressLookupRequest)

Aggregations

AddressLookupRequest (net.osmand.plus.GeocodingLookupService.AddressLookupRequest)10 LatLon (net.osmand.data.LatLon)4 PointDescription (net.osmand.data.PointDescription)3 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)3 Spinner (android.widget.Spinner)2 ArrayList (java.util.ArrayList)2 OnAddressLookupResult (net.osmand.plus.GeocodingLookupService.OnAddressLookupResult)2 TargetPointsHelper (net.osmand.plus.TargetPointsHelper)2 GeocodingLookupService (net.osmand.plus.GeocodingLookupService)1