forked from organicmaps/organicmaps
[deeplink][android][ios] fix for search in list deep link.
This commit is contained in:
parent
b84ebe53da
commit
972b159b3e
7 changed files with 48 additions and 22 deletions
|
@ -2126,11 +2126,11 @@ Java_com_mapswithme_maps_Framework_nativeSetPowerManagerScheme(JNIEnv *, jclass,
|
|||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeSetViewportCenter(JNIEnv *, jclass, jdouble lat,
|
||||
jdouble lon, jint zoom)
|
||||
jdouble lon, jint zoom, jboolean isAnim)
|
||||
{
|
||||
auto const center = MercatorBounds::FromLatLon(static_cast<double>(lat),
|
||||
static_cast<double>(lon));
|
||||
frm()->SetViewportCenter(center, static_cast<int>(zoom));
|
||||
frm()->SetViewportCenter(center, static_cast<int>(zoom), static_cast<bool>(isAnim));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
|
@ -2138,4 +2138,14 @@ Java_com_mapswithme_maps_Framework_nativeStopLocationFollow(JNIEnv *, jclass)
|
|||
{
|
||||
frm()->StopLocationFollow();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeSetSearchViewport(JNIEnv *, jclass, jdouble lat,
|
||||
jdouble lon, jint zoom)
|
||||
{
|
||||
auto const center = MercatorBounds::FromLatLon(static_cast<double>(lat),
|
||||
static_cast<double>(lon));
|
||||
auto const rect = df::GetRectForDrawScale(static_cast<int>(zoom), center);
|
||||
frm()->GetSearchAPI().OnViewportChanged(rect);
|
||||
}
|
||||
} // extern "C"
|
||||
|
|
|
@ -519,9 +519,12 @@ public class Framework
|
|||
public static native void nativeSetPowerManagerFacility(int facilityType, boolean state);
|
||||
public static native int nativeGetPowerManagerScheme();
|
||||
public static native void nativeSetPowerManagerScheme(int schemeType);
|
||||
public static native void nativeSetViewportCenter(double lat, double lon, int zoom);
|
||||
public static native void nativeSetViewportCenter(double lat, double lon, int zoom,
|
||||
boolean isAnim);
|
||||
public static native void nativeStopLocationFollow();
|
||||
|
||||
public static native void nativeSetSearchViewport(double lat, double lon, int zoom);
|
||||
|
||||
public enum LocalAdsEventType
|
||||
{
|
||||
LOCAL_ADS_EVENT_SHOW_POINT,
|
||||
|
|
|
@ -807,10 +807,15 @@ public class Factory
|
|||
return true;
|
||||
case ParsedUrlMwmRequest.RESULT_SEARCH:
|
||||
final ParsedSearchRequest request = Framework.nativeGetParsedSearchRequest();
|
||||
if (request.mIsSearchOnMap && (request.mLat != 0.0 || request.mLon != 0.0))
|
||||
if (request.mLat != 0.0 || request.mLon != 0.0)
|
||||
{
|
||||
Framework.nativeStopLocationFollow();
|
||||
Framework.nativeSetViewportCenter(request.mLat, request.mLon, SEARCH_IN_VIEWPORT_ZOOM);
|
||||
Framework.nativeSetViewportCenter(request.mLat, request.mLon, SEARCH_IN_VIEWPORT_ZOOM,
|
||||
false);
|
||||
// We need to update viewport for search api manually because of drape engine
|
||||
// will not notify subscribers when search activity is shown.
|
||||
if (!request.mIsSearchOnMap)
|
||||
Framework.nativeSetSearchViewport(request.mLat, request.mLon, SEARCH_IN_VIEWPORT_ZOOM);
|
||||
}
|
||||
SearchActivity.start(target, request.mQuery, request.mLocale, request.mIsSearchOnMap,
|
||||
null, null);
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
#import "MWMCoreRouterType.h"
|
||||
#import "MWMMapViewControlsManager.h"
|
||||
|
||||
static NSInteger const kSearchInViewportZoom = 16;
|
||||
#include "drape_frontend/visual_params.hpp"
|
||||
|
||||
#include "geometry/mercator.hpp"
|
||||
|
||||
@implementation DeepLinkHelper
|
||||
|
||||
|
@ -68,19 +70,30 @@ static NSInteger const kSearchInViewportZoom = 16;
|
|||
[MapsAppDelegate.theApp showMap];
|
||||
break;
|
||||
case ParsedMapApi::ParsingResult::Search: {
|
||||
int constexpr kSearchInViewportZoom = 16;
|
||||
|
||||
auto const &request = f.GetParsedSearchRequest();
|
||||
|
||||
auto query = [@((request.m_query + " ").c_str()) stringByRemovingPercentEncoding];
|
||||
auto locale = @(request.m_locale.c_str());
|
||||
|
||||
if (request.m_isSearchOnMap) {
|
||||
// Set viewport only when cll parameter was provided in url.
|
||||
if (request.m_centerLat != 0.0 || request.m_centerLon != 0.0) {
|
||||
[MapViewController setViewport:request.m_centerLat
|
||||
lon:request.m_centerLon
|
||||
zoomLevel:kSearchInViewportZoom];
|
||||
// Set viewport only when cll parameter was provided in url.
|
||||
if (request.m_centerLat != 0.0 || request.m_centerLon != 0.0) {
|
||||
[MapViewController setViewport:request.m_centerLat
|
||||
lon:request.m_centerLon
|
||||
zoomLevel:kSearchInViewportZoom];
|
||||
|
||||
// We need to update viewport for search api manually because of drape engine
|
||||
// will not notify subscribers when search view is shown.
|
||||
if (!request.m_isSearchOnMap)
|
||||
{
|
||||
auto const center = MercatorBounds::FromLatLon(request.m_centerLat, request.m_centerLon);
|
||||
auto const rect = df::GetRectForDrawScale(kSearchInViewportZoom, center);
|
||||
f.GetSearchAPI().OnViewportChanged(rect);
|
||||
}
|
||||
}
|
||||
|
||||
if (request.m_isSearchOnMap) {
|
||||
[MWMMapViewControlsManager.manager searchTextOnMap:query forInputLocale:locale];
|
||||
} else {
|
||||
[MWMMapViewControlsManager.manager searchText:query forInputLocale:locale];
|
||||
|
|
|
@ -771,7 +771,7 @@ BOOL gIsFirstMyPositionMode = YES;
|
|||
f.StopLocationFollow();
|
||||
|
||||
auto const center = MercatorBounds::FromLatLon(lat, lon);
|
||||
f.SetViewportCenter(center, zoomLevel);
|
||||
f.SetViewportCenter(center, zoomLevel, false);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1212,15 +1212,11 @@ m2::PointD const & Framework::GetViewportCenter() const
|
|||
return m_currentModelView.GetOrg();
|
||||
}
|
||||
|
||||
void Framework::SetViewportCenter(m2::PointD const & pt)
|
||||
{
|
||||
SetViewportCenter(pt, -1);
|
||||
}
|
||||
|
||||
void Framework::SetViewportCenter(m2::PointD const & pt, int zoomLevel)
|
||||
void Framework::SetViewportCenter(m2::PointD const & pt, int zoomLevel /* = -1 */,
|
||||
bool isAnim /* = true */)
|
||||
{
|
||||
if (m_drapeEngine != nullptr)
|
||||
m_drapeEngine->SetModelViewCenter(pt, zoomLevel, true /* isAnim */, false /* trackVisibleViewport */);
|
||||
m_drapeEngine->SetModelViewCenter(pt, zoomLevel, isAnim, false /* trackVisibleViewport */);
|
||||
}
|
||||
|
||||
m2::RectD Framework::GetCurrentViewport() const
|
||||
|
|
|
@ -629,8 +629,7 @@ public:
|
|||
m2::PointD GetVisiblePixelCenter() const;
|
||||
|
||||
m2::PointD const & GetViewportCenter() const;
|
||||
void SetViewportCenter(m2::PointD const & pt);
|
||||
void SetViewportCenter(m2::PointD const & pt, int zoomLevel);
|
||||
void SetViewportCenter(m2::PointD const & pt, int zoomLevel = -1, bool isAnim = true);
|
||||
|
||||
m2::RectD GetCurrentViewport() const;
|
||||
void SetVisibleViewport(m2::RectD const & rect);
|
||||
|
|
Loading…
Add table
Reference in a new issue