diff --git a/iphone/CoreApi/CoreApi/Traffic/MWMMapOverlayManager.h b/iphone/CoreApi/CoreApi/Traffic/MWMMapOverlayManager.h index 707ba1168b..a7dd86ae46 100644 --- a/iphone/CoreApi/CoreApi/Traffic/MWMMapOverlayManager.h +++ b/iphone/CoreApi/CoreApi/Traffic/MWMMapOverlayManager.h @@ -17,6 +17,13 @@ typedef NS_ENUM(NSUInteger, MWMMapOverlayTransitState) { MWMMapOverlayTransitStateNoData, } NS_SWIFT_NAME(MapOverlayTransitState); +typedef NS_ENUM(NSUInteger, MWMMapOverlayIsolinesState) { + MWMMapOverlayIsolinesStateDisabled, + MWMMapOverlayIsolinesStateEnabled, + MWMMapOverlayIsolinesStateExpiredData, + MWMMapOverlayIsolinesStateNoData, +} NS_SWIFT_NAME(MapOverlayTransitState); + NS_SWIFT_NAME(MapOverlayManagerObserver) @protocol MWMMapOverlayManagerObserver @@ -36,6 +43,7 @@ NS_SWIFT_NAME(MapOverlayManager) + (MWMMapOverlayTrafficState)trafficState; + (MWMMapOverlayTransitState)transitState; ++ (MWMMapOverlayIsolinesState)isolinesState; + (BOOL)trafficEnabled; + (BOOL)transitEnabled; diff --git a/iphone/CoreApi/CoreApi/Traffic/MWMMapOverlayManager.mm b/iphone/CoreApi/CoreApi/Traffic/MWMMapOverlayManager.mm index cbe86504a4..75cca7076d 100644 --- a/iphone/CoreApi/CoreApi/Traffic/MWMMapOverlayManager.mm +++ b/iphone/CoreApi/CoreApi/Traffic/MWMMapOverlayManager.mm @@ -8,6 +8,7 @@ @property(nonatomic) TrafficManager::TrafficState trafficState; @property(nonatomic) TransitReadManager::TransitSchemeState transitState; +@property(nonatomic) IsolinesManager::IsolinesState isolinesState; @end @@ -42,6 +43,14 @@ } } }); + GetFramework().GetIsolinesManager().SetStateListener([self](IsolinesManager::IsolinesState state) { + self.isolinesState = state; + for (id observer in self.observers) { + if ([observer respondsToSelector:@selector(onIsoLinesStateUpdated)]) { + [observer onIsoLinesStateUpdated]; + } + } + }); } return self; } @@ -88,6 +97,19 @@ } } ++ (MWMMapOverlayIsolinesState)isolinesState { + switch ([MWMMapOverlayManager manager].isolinesState) { + case IsolinesManager::IsolinesState::Disabled: + return MWMMapOverlayIsolinesStateDisabled; + case IsolinesManager::IsolinesState::Enabled: + return MWMMapOverlayIsolinesStateEnabled; + case IsolinesManager::IsolinesState::ExpiredData: + return MWMMapOverlayIsolinesStateExpiredData; + case IsolinesManager::IsolinesState::NoData: + return MWMMapOverlayIsolinesStateNoData; + } +} + + (BOOL)trafficEnabled { return [MWMMapOverlayManager manager].trafficState != TrafficManager::TrafficState::Disabled; } @@ -97,7 +119,7 @@ } + (BOOL)isoLinesEnabled { - return GetFramework().LoadIsolinesEnabled(); + return [MWMMapOverlayManager manager].isolinesState != IsolinesManager::IsolinesState::Disabled; } + (void)setTrafficEnabled:(BOOL)enable { @@ -131,12 +153,6 @@ auto &f = GetFramework(); f.GetIsolinesManager().SetEnabled(enable); f.SaveIsolonesEnabled(enable); - - for (id observer in [MWMMapOverlayManager manager].observers) { - if ([observer respondsToSelector:@selector(onIsoLinesStateUpdated)]) { - [observer onIsoLinesStateUpdated]; - } - } } @end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/TrafficButton/MWMTrafficButtonViewController.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/TrafficButton/MWMTrafficButtonViewController.mm index f1e8557e53..800faca757 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/TrafficButton/MWMTrafficButtonViewController.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/TrafficButton/MWMTrafficButtonViewController.mm @@ -146,6 +146,10 @@ NSArray * imagesWithName(NSString * name) else if ([MWMMapOverlayManager isoLinesEnabled]) { btn.imageName = @"btn_isoMap_on"; + if ([MWMMapOverlayManager isolinesState] == MWMMapOverlayIsolinesStateNoData) + [[MWMToast toastWithText:L(@"isolines_location_error_dialog")] show]; + else if ([MWMMapOverlayManager isolinesState] == MWMMapOverlayIsolinesStateExpiredData) + [MWMAlertViewController.activeAlertController presentInfoAlert:L(@"isolines_activation_error_dialog") text:@""]; } else {