Search in sources :

Example 1 with AddressLookupRequest

use of net.osmand.plus.GeocodingLookupService.AddressLookupRequest in project Osmand by osmandapp.

the class TargetPointsHelper method lookupAddessForStartPoint.

private void lookupAddessForStartPoint() {
    if (pointToStart != null && pointToStart.isSearchingAddress(ctx) && (startPointRequest == null || !startPointRequest.getLatLon().equals(pointToStart.point))) {
        cancelStartPointAddressRequest();
        startPointRequest = new AddressLookupRequest(pointToStart.point, new GeocodingLookupService.OnAddressLookupResult() {

            @Override
            public void geocodingDone(String address) {
                startPointRequest = null;
                if (pointToStart != null) {
                    pointToStart.pointDescription.setName(address);
                    settings.setPointToStart(pointToStart.point.getLatitude(), pointToStart.point.getLongitude(), pointToStart.pointDescription);
                    updateRouteAndRefresh(false);
                    updateTargetPoint(pointToStart);
                }
            }
        }, null);
        ctx.getGeocodingLookupService().lookupAddress(startPointRequest);
    }
}
Also used : AddressLookupRequest(net.osmand.plus.GeocodingLookupService.AddressLookupRequest)

Example 2 with AddressLookupRequest

use of net.osmand.plus.GeocodingLookupService.AddressLookupRequest in project Osmand by osmandapp.

the class MenuTitleController method acquireStreetName.

protected void acquireStreetName() {
    addressLookupRequest = new AddressLookupRequest(getLatLon(), new GeocodingLookupService.OnAddressLookupResult() {

        @Override
        public void geocodingDone(String address) {
            if (addressLookupRequest != null) {
                addressLookupRequest = null;
                if (Algorithms.isEmpty(address)) {
                    streetStr = PointDescription.getAddressNotFoundStr(getMapActivity());
                } else {
                    streetStr = address;
                }
                if (displayStreetNameInTitle()) {
                    nameStr = streetStr;
                    getPointDescription().setName(nameStr);
                }
                onSearchAddressDone();
            }
        }
    }, new GeocodingLookupService.OnAddressLookupProgress() {

        @Override
        public void geocodingInProgress() {
        // animate three dots
        }
    });
    getMapActivity().getMyApplication().getGeocodingLookupService().lookupAddress(addressLookupRequest);
}
Also used : AddressLookupRequest(net.osmand.plus.GeocodingLookupService.AddressLookupRequest)

Example 3 with AddressLookupRequest

use of net.osmand.plus.GeocodingLookupService.AddressLookupRequest in project Osmand by osmandapp.

the class MapRouteInfoMenu method setupToSpinner.

private Spinner setupToSpinner(View view) {
    final Spinner toSpinner = ((Spinner) view.findViewById(R.id.ToSpinner));
    final TargetPointsHelper targets = getTargets();
    List<RouteSpinnerRow> toActions = new ArrayList<>();
    TargetPoint finish = getTargets().getPointToNavigate();
    if (finish != null) {
        toActions.add(new RouteSpinnerRow(SPINNER_FINISH_ID, R.drawable.ic_action_get_my_location, getRoutePointDescription(targets.getPointToNavigate().point, targets.getPointToNavigate().getOnlyName())));
        final LatLon latLon = finish.point;
        final PointDescription pointDescription = finish.getOriginalPointDescription();
        boolean needAddress = pointDescription != null && pointDescription.isSearchingAddress(mapActivity);
        cancelTargetPointAddressRequest();
        if (needAddress) {
            targetPointRequest = new AddressLookupRequest(latLon, new GeocodingLookupService.OnAddressLookupResult() {

                @Override
                public void geocodingDone(String address) {
                    targetPointRequest = null;
                    updateMenu();
                }
            }, null);
            geocodingLookupService.lookupAddress(targetPointRequest);
        }
    } else {
        toSpinner.setPromptId(R.string.route_descr_select_destination);
        toActions.add(new RouteSpinnerRow(SPINNER_HINT_ID, R.drawable.ic_action_get_my_location, mapActivity.getString(R.string.route_descr_select_destination)));
    }
    toActions.add(new RouteSpinnerRow(SPINNER_FAV_ID, R.drawable.ic_action_fav_dark, mapActivity.getString(R.string.shared_string_favorite) + mapActivity.getString(R.string.shared_string_ellipsis)));
    toActions.add(new RouteSpinnerRow(SPINNER_MAP_ID, R.drawable.ic_action_marker_dark, mapActivity.getString(R.string.shared_string_select_on_map)));
    toActions.add(new RouteSpinnerRow(SPINNER_ADDRESS_ID, R.drawable.ic_action_home_dark, mapActivity.getString(R.string.shared_string_address) + mapActivity.getString(R.string.shared_string_ellipsis)));
    addMarkersToSpinner(toActions);
    RouteSpinnerArrayAdapter toAdapter = new RouteSpinnerArrayAdapter(view.getContext());
    for (RouteSpinnerRow row : toActions) {
        toAdapter.add(row);
    }
    toSpinner.setAdapter(toAdapter);
    return toSpinner;
}
Also used : Spinner(android.widget.Spinner) ArrayList(java.util.ArrayList) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription) TargetPointsHelper(net.osmand.plus.TargetPointsHelper) AddressLookupRequest(net.osmand.plus.GeocodingLookupService.AddressLookupRequest)

Example 4 with AddressLookupRequest

use of net.osmand.plus.GeocodingLookupService.AddressLookupRequest in project Osmand by osmandapp.

the class MapRouteInfoMenu method setupFromSpinner.

private Spinner setupFromSpinner(View view) {
    List<RouteSpinnerRow> fromActions = new ArrayList<>();
    fromActions.add(new RouteSpinnerRow(SPINNER_MY_LOCATION_ID, R.drawable.ic_action_get_my_location, mapActivity.getString(R.string.shared_string_my_location)));
    fromActions.add(new RouteSpinnerRow(SPINNER_FAV_ID, R.drawable.ic_action_fav_dark, mapActivity.getString(R.string.shared_string_favorite) + mapActivity.getString(R.string.shared_string_ellipsis)));
    fromActions.add(new RouteSpinnerRow(SPINNER_MAP_ID, R.drawable.ic_action_marker_dark, mapActivity.getString(R.string.shared_string_select_on_map)));
    fromActions.add(new RouteSpinnerRow(SPINNER_ADDRESS_ID, R.drawable.ic_action_home_dark, mapActivity.getString(R.string.shared_string_address) + mapActivity.getString(R.string.shared_string_ellipsis)));
    TargetPoint start = getTargets().getPointToStart();
    int startPos = -1;
    if (start != null) {
        String oname = start.getOnlyName().length() > 0 ? start.getOnlyName() : (mapActivity.getString(R.string.route_descr_map_location) + " " + getRoutePointDescription(start.getLatitude(), start.getLongitude()));
        startPos = fromActions.size();
        fromActions.add(new RouteSpinnerRow(SPINNER_START_ID, R.drawable.ic_action_get_my_location, oname));
        final LatLon latLon = start.point;
        final PointDescription pointDescription = start.getOriginalPointDescription();
        boolean needAddress = pointDescription != null && pointDescription.isSearchingAddress(mapActivity);
        cancelStartPointAddressRequest();
        if (needAddress) {
            startPointRequest = new AddressLookupRequest(latLon, new GeocodingLookupService.OnAddressLookupResult() {

                @Override
                public void geocodingDone(String address) {
                    startPointRequest = null;
                    updateMenu();
                }
            }, null);
            geocodingLookupService.lookupAddress(startPointRequest);
        }
    }
    addMarkersToSpinner(fromActions);
    final Spinner fromSpinner = ((Spinner) view.findViewById(R.id.FromSpinner));
    RouteSpinnerArrayAdapter fromAdapter = new RouteSpinnerArrayAdapter(view.getContext());
    for (RouteSpinnerRow row : fromActions) {
        fromAdapter.add(row);
    }
    fromSpinner.setAdapter(fromAdapter);
    if (start != null) {
        fromSpinner.setSelection(startPos);
    } else {
        if (mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation() == null) {
            fromSpinner.setPromptId(R.string.search_poi_location);
        }
    // fromSpinner.setSelection(0);
    }
    return fromSpinner;
}
Also used : Spinner(android.widget.Spinner) ArrayList(java.util.ArrayList) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription) AddressLookupRequest(net.osmand.plus.GeocodingLookupService.AddressLookupRequest)

Example 5 with AddressLookupRequest

use of net.osmand.plus.GeocodingLookupService.AddressLookupRequest in project Osmand by osmandapp.

the class MapMarkersHelper method lookupAddress.

private void lookupAddress(final MapMarker mapMarker) {
    if (mapMarker != null && mapMarker.pointDescription.isSearchingAddress(ctx)) {
        cancelPointAddressRequests(mapMarker.point);
        AddressLookupRequest lookupRequest = new AddressLookupRequest(mapMarker.point, new GeocodingLookupService.OnAddressLookupResult() {

            @Override
            public void geocodingDone(String address) {
                if (Algorithms.isEmpty(address)) {
                    mapMarker.pointDescription.setName(PointDescription.getAddressNotFoundStr(ctx));
                } else {
                    mapMarker.pointDescription.setName(address);
                }
                markersDbHelper.updateMarker(mapMarker);
                refreshMarker(mapMarker);
            }
        }, null);
        ctx.getGeocodingLookupService().lookupAddress(lookupRequest);
    }
}
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