From 8a331c4c673c6b7d130abac48b43f2ae32130489 Mon Sep 17 00:00:00 2001 From: Kiryl Kaveryn Date: Mon, 26 May 2025 17:27:21 +0400 Subject: [PATCH] [ios] fix route building error while searching when current location in none Fixes issue https://github.com/organicmaps/organicmaps/issues/10606 Signed-off-by: Kiryl Kaveryn --- iphone/Maps/Core/Search/SearchResult.mm | 10 +++++----- .../SearchOnMap/SearchOnMapInteractor.swift | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/iphone/Maps/Core/Search/SearchResult.mm b/iphone/Maps/Core/Search/SearchResult.mm index ea47d4f18..da8b8c897 100644 --- a/iphone/Maps/Core/Search/SearchResult.mm +++ b/iphone/Maps/Core/Search/SearchResult.mm @@ -36,16 +36,16 @@ if (result.IsSuggest()) _suggestion = @(result.GetSuggestionString().c_str()); + auto const & pivot = result.GetFeatureCenter(); + _point = CGPointMake(pivot.x, pivot.y); + auto const location = mercator::ToLatLon(pivot); + _coordinate = CLLocationCoordinate2DMake(location.m_lat, location.m_lon); + CLLocation * lastLocation = [MWMLocationManager lastLocation]; if (lastLocation && result.HasPoint()) { double distanceInMeters = mercator::DistanceOnEarth(lastLocation.mercator, result.GetFeatureCenter()); std::string distanceStr = platform::Distance::CreateFormatted(distanceInMeters).ToString(); _distanceText = @(distanceStr.c_str()); - - auto const & pivot = result.GetFeatureCenter(); - _point = CGPointMake(pivot.x, pivot.y); - auto const location = mercator::ToLatLon(pivot); - _coordinate = CLLocationCoordinate2DMake(location.m_lat, location.m_lon); } else { _distanceText = nil; } diff --git a/iphone/Maps/UI/Search/SearchOnMap/SearchOnMapInteractor.swift b/iphone/Maps/UI/Search/SearchOnMap/SearchOnMapInteractor.swift index d77f9ced6..37ee3eb7b 100644 --- a/iphone/Maps/UI/Search/SearchOnMap/SearchOnMapInteractor.swift +++ b/iphone/Maps/UI/Search/SearchOnMap/SearchOnMapInteractor.swift @@ -96,24 +96,24 @@ final class SearchOnMapInteractor: NSObject { searchManager.showResult(at: result.index) case .start: let point = MWMRoutePoint(cgPoint: result.point, - title: result.titleText, - subtitle: result.addressText, - type: .start, - intermediateIndex: 0) + title: result.titleText, + subtitle: result.addressText, + type: .start, + intermediateIndex: 0) routeManager.build(from: point, bestRouter: false) case .finish: let point = MWMRoutePoint(cgPoint: result.point, - title: result.titleText, - subtitle: result.addressText, - type: .finish, - intermediateIndex: 0) + title: result.titleText, + subtitle: result.addressText, + type: .finish, + intermediateIndex: 0) routeManager.build(to: point, bestRouter: false) @unknown default: fatalError("Unsupported routingTooltipSearch") } return isIPad ? .none : .setSearchScreenHidden(true) case .suggestion: - var suggestionQuery = SearchQuery(result.suggestion, + let suggestionQuery = SearchQuery(result.suggestion, locale: query.locale, source: result.isPureSuggest ? .suggestion : .typedText) searchManager.searchQuery(suggestionQuery)