Skip to content

Commit 0e1b828

Browse files
committed
When the map view appears it will reset up the MapDelegate to properly order layers
1 parent 17d33ed commit 0e1b828

File tree

4 files changed

+54
-47
lines changed

4 files changed

+54
-47
lines changed

Mage/MapDelegate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,6 @@
6363
- (void) cleanup;
6464
- (void) ensureMapLayout;
6565
- (void) updateTheme;
66+
- (void) setupListeners;
6667

6768
@end

Mage/MapDelegate.m

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -87,46 +87,50 @@ @implementation MapDelegate
8787

8888
- (id) init {
8989
if (self = [super init]) {
90-
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
91-
[defaults addObserver:self
92-
forKeyPath:@"mapType"
93-
options:NSKeyValueObservingOptionNew
94-
context:NULL];
95-
96-
[defaults addObserver:self
97-
forKeyPath:kCurrentEventIdKey
98-
options:NSKeyValueObservingOptionNew
99-
context:NULL];
100-
101-
if (!self.hideStaticLayers) {
102-
[defaults addObserver:self
103-
forKeyPath:@"selectedStaticLayers"
104-
options:NSKeyValueObservingOptionNew
105-
context:NULL];
106-
}
107-
90+
[self setupListeners];
91+
}
92+
93+
return self;
94+
}
95+
96+
- (void) setupListeners {
97+
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
98+
[defaults addObserver:self
99+
forKeyPath:@"mapType"
100+
options:NSKeyValueObservingOptionNew
101+
context:NULL];
102+
103+
[defaults addObserver:self
104+
forKeyPath:kCurrentEventIdKey
105+
options:NSKeyValueObservingOptionNew
106+
context:NULL];
107+
108+
if (!self.hideStaticLayers) {
108109
[defaults addObserver:self
109-
forKeyPath:@"selectedOnlineLayers"
110+
forKeyPath:@"selectedStaticLayers"
110111
options:NSKeyValueObservingOptionNew
111112
context:NULL];
112-
113-
self.mapCacheOverlays = [[NSMutableDictionary alloc] init];
114-
[[CacheOverlays getInstance] registerListener:self];
115-
self.cacheOverlayUpdate = nil;
116-
self.cacheOverlayUpdateLock = [[NSObject alloc] init];
117-
self.updatingCacheOverlays = false;
118-
self.waitingCacheOverlaysUpdate = false;
119-
GPKGGeoPackageManager * geoPackageManager = [GPKGGeoPackageFactory manager];
120-
self.geoPackageCache = [[GPKGGeoPackageCache alloc]initWithManager:geoPackageManager];
121-
122-
self.locationManager = [[CLLocationManager alloc] init];
123-
self.locationManager.delegate = self;
124-
125-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(formFetched:) name: MAGEFormFetched object:nil];
126-
self.darkMode = false;
127113
}
128114

129-
return self;
115+
[defaults addObserver:self
116+
forKeyPath:@"selectedOnlineLayers"
117+
options:NSKeyValueObservingOptionNew
118+
context:NULL];
119+
120+
self.mapCacheOverlays = [[NSMutableDictionary alloc] init];
121+
[[CacheOverlays getInstance] registerListener:self];
122+
self.cacheOverlayUpdate = nil;
123+
self.cacheOverlayUpdateLock = [[NSObject alloc] init];
124+
self.updatingCacheOverlays = false;
125+
self.waitingCacheOverlaysUpdate = false;
126+
GPKGGeoPackageManager * geoPackageManager = [GPKGGeoPackageFactory manager];
127+
self.geoPackageCache = [[GPKGGeoPackageCache alloc]initWithManager:geoPackageManager];
128+
129+
self.locationManager = [[CLLocationManager alloc] init];
130+
self.locationManager.delegate = self;
131+
132+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(formFetched:) name: MAGEFormFetched object:nil];
133+
self.darkMode = false;
130134
}
131135

132136
// map annotation drop code from: https://stackoverflow.com/questions/6808876/how-do-i-animate-mkannotationview-drop

Mage/MapViewController.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ - (void) viewDidLoad {
121121
- (void) viewWillAppear:(BOOL)animated {
122122
[super viewWillAppear:animated];
123123

124+
[self.mapDelegate setupListeners];
125+
124126
if (self.mapDelegate.locations != nil) {
125127
[self.mapDelegate updateLocationPredicates:[Locations getPredicatesForLocations]];
126128
NSError *error;

Podfile.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ PODS:
3434
- GoogleToolboxForMac/Defines (= 2.2.2)
3535
- "GoogleToolboxForMac/NSString+URLArguments (= 2.2.2)"
3636
- "GoogleToolboxForMac/NSString+URLArguments (2.2.2)"
37-
- GTMSessionFetcher/Core (1.3.0)
37+
- GTMSessionFetcher/Core (1.3.1)
3838
- HexColors (2.2.1)
3939
- KTCenterFlowLayout (1.3.1)
4040
- libPhoneNumber-iOS (0.9.15)
@@ -48,22 +48,22 @@ PODS:
4848
- MagicalRecord/Core (= 2.3.2)
4949
- MagicalRecord/Core (2.3.2)
5050
- mgrs (0.1.0)
51-
- OCMock (3.5)
51+
- OCMock (3.6)
5252
- ogc-api-features-json-ios (1.0.0):
5353
- sf-geojson-ios (~> 1.0.0)
54-
- OHHTTPStubs (8.0.0):
55-
- OHHTTPStubs/Default (= 8.0.0)
56-
- OHHTTPStubs/Core (8.0.0)
57-
- OHHTTPStubs/Default (8.0.0):
54+
- OHHTTPStubs (9.0.0):
55+
- OHHTTPStubs/Default (= 9.0.0)
56+
- OHHTTPStubs/Core (9.0.0)
57+
- OHHTTPStubs/Default (9.0.0):
5858
- OHHTTPStubs/Core
5959
- OHHTTPStubs/JSON
6060
- OHHTTPStubs/NSURLSession
6161
- OHHTTPStubs/OHPathHelpers
62-
- OHHTTPStubs/JSON (8.0.0):
62+
- OHHTTPStubs/JSON (9.0.0):
6363
- OHHTTPStubs/Core
64-
- OHHTTPStubs/NSURLSession (8.0.0):
64+
- OHHTTPStubs/NSURLSession (9.0.0):
6565
- OHHTTPStubs/Core
66-
- OHHTTPStubs/OHPathHelpers (8.0.0)
66+
- OHHTTPStubs/OHPathHelpers (9.0.0)
6767
- proj4-ios (4.9.3)
6868
- sf-geojson-ios (1.0.0):
6969
- sf-ios (~> 2.0.3)
@@ -145,16 +145,16 @@ SPEC CHECKSUMS:
145145
geopackage-ios: 43f401e530b9db603f603c214ce3d1e5e005444c
146146
GoogleSignIn: 7ff245e1a7b26d379099d3243a562f5747e23d39
147147
GoogleToolboxForMac: 800648f8b3127618c1b59c7f97684427630c5ea3
148-
GTMSessionFetcher: 43b8b64263023d4f32caa0b40f4c8bfa3c5f36d8
148+
GTMSessionFetcher: cea130bbfe5a7edc8d06d3f0d17288c32ffe9925
149149
HexColors: abfd172e329dab59888614ccba6f216cec59289d
150150
KTCenterFlowLayout: 6e02b50ab2bd865025ae82fe266ed13b6d9eaf97
151151
libPhoneNumber-iOS: 0a32a9525cf8744fe02c5206eb30d571e38f7d75
152152
mage-ios-sdk: 444ce8630ec14188f1976d3f83ab30f5019538f9
153153
MagicalRecord: 53bed74b4323b930992a725be713e53b37d19755
154154
mgrs: c4b57f8c27ee1f4939be117f4a683e680c127326
155-
OCMock: 4ab4577fc941af31f4a0398f6e7e230cf21fc72a
155+
OCMock: 5ea90566be239f179ba766fd9fbae5885040b992
156156
ogc-api-features-json-ios: 2f733b450d22a73517a5e86fd9241747e039ccb0
157-
OHHTTPStubs: 9cbce6364bec557cc3439aa6bb7514670d780881
157+
OHHTTPStubs: cb29d2a9d09a828ecb93349a2b0c64f99e0db89f
158158
proj4-ios: fa2f3ab9ba9ba727bd10bc12aea735d0c3927ef4
159159
sf-geojson-ios: ef76082c7fac4e594b35e1016113d0dbe164b730
160160
sf-ios: 4ca0618351be80afac4e0961860d632dd85ab739

0 commit comments

Comments
 (0)