Move and rename iOS project so it works with KMM plugin
Enables iOS KMP debug on device in Android Studio
This commit is contained in:
21
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/AnimatedCurrentLocationViewController.h
generated
Executable file
21
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/AnimatedCurrentLocationViewController.h
generated
Executable file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <CoreLocation/CoreLocation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface AnimatedCurrentLocationViewController : UIViewController <CLLocationManagerDelegate>
|
||||
|
||||
@end
|
||||
105
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/AnimatedCurrentLocationViewController.m
generated
Executable file
105
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/AnimatedCurrentLocationViewController.m
generated
Executable file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/AnimatedCurrentLocationViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@implementation AnimatedCurrentLocationViewController {
|
||||
CLLocationManager *_manager;
|
||||
GMSMapView *_mapView;
|
||||
GMSMarker *_locationMarker;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:38.8879
|
||||
longitude:-77.0200
|
||||
zoom:17];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
_mapView.settings.myLocationButton = NO;
|
||||
_mapView.settings.indoorPicker = NO;
|
||||
|
||||
self.view = _mapView;
|
||||
|
||||
// Setup location services
|
||||
if (![CLLocationManager locationServicesEnabled]) {
|
||||
NSLog(@"Please enable location services");
|
||||
return;
|
||||
}
|
||||
|
||||
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) {
|
||||
NSLog(@"Please authorize location services");
|
||||
return;
|
||||
}
|
||||
|
||||
_manager = [[CLLocationManager alloc] init];
|
||||
if ([_manager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
|
||||
[_manager requestWhenInUseAuthorization];
|
||||
}
|
||||
_manager.delegate = self;
|
||||
_manager.desiredAccuracy = kCLLocationAccuracyBest;
|
||||
_manager.distanceFilter = 5.0f;
|
||||
[_manager startUpdatingLocation];
|
||||
}
|
||||
|
||||
#pragma mark - CLLocationManagerDelegate
|
||||
|
||||
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
|
||||
if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) {
|
||||
NSLog(@"Please authorize location services");
|
||||
return;
|
||||
}
|
||||
|
||||
NSLog(@"CLLocationManager error: %@", error.localizedFailureReason);
|
||||
return;
|
||||
}
|
||||
|
||||
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
|
||||
CLLocation *location = [locations lastObject];
|
||||
|
||||
if (_locationMarker == nil) {
|
||||
_locationMarker = [[GMSMarker alloc] init];
|
||||
_locationMarker.position = location.coordinate;
|
||||
|
||||
// Animated walker images derived from a www.angryanimator.com tutorial.
|
||||
// See: http://www.angryanimator.com/word/2010/11/26/tutorial-2-walk-cycle/
|
||||
|
||||
NSArray *frames = @[
|
||||
[UIImage imageNamed:@"step1"], [UIImage imageNamed:@"step2"], [UIImage imageNamed:@"step3"],
|
||||
[UIImage imageNamed:@"step4"], [UIImage imageNamed:@"step5"], [UIImage imageNamed:@"step6"],
|
||||
[UIImage imageNamed:@"step7"], [UIImage imageNamed:@"step8"]
|
||||
];
|
||||
|
||||
_locationMarker.icon = [UIImage animatedImageWithImages:frames duration:0.8];
|
||||
_locationMarker.groundAnchor = CGPointMake(0.5f, 0.97f); // Taking into account walker's shadow
|
||||
_locationMarker.map = _mapView;
|
||||
} else {
|
||||
[CATransaction begin];
|
||||
[CATransaction setAnimationDuration:2.0];
|
||||
_locationMarker.position = location.coordinate;
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
GMSCameraUpdate *move = [GMSCameraUpdate setTarget:location.coordinate zoom:17];
|
||||
[_mapView animateWithCameraUpdate:move];
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/AnimatedUIViewMarkerViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/AnimatedUIViewMarkerViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface AnimatedUIViewMarkerViewController : UIViewController
|
||||
|
||||
@end
|
||||
137
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/AnimatedUIViewMarkerViewController.m
generated
Executable file
137
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/AnimatedUIViewMarkerViewController.m
generated
Executable file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/AnimatedUIViewMarkerViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
/** Returns a random value from 0-1.0f. */
|
||||
static CGFloat randf() { return (((float)arc4random() / 0x100000000) * 1.0f); }
|
||||
|
||||
@interface AnimatedUIViewMarkerViewController () <GMSMapViewDelegate>
|
||||
@end
|
||||
|
||||
@implementation AnimatedUIViewMarkerViewController {
|
||||
GMSMapView *_mapView;
|
||||
UIView *_infoView;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.8683
|
||||
longitude:151.2086
|
||||
zoom:5];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
_mapView.delegate = self;
|
||||
|
||||
self.view = _mapView;
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated {
|
||||
[super viewWillAppear:animated];
|
||||
[NSNotificationCenter.defaultCenter addObserver:self
|
||||
selector:@selector(applicationWillEnterForeground)
|
||||
name:UIApplicationWillEnterForegroundNotification
|
||||
object:nil];
|
||||
[_mapView clear];
|
||||
[self addDefaultMarker];
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground {
|
||||
[_mapView clear];
|
||||
[self addDefaultMarker];
|
||||
}
|
||||
|
||||
- (void)viewWillDisappear:(BOOL)animated {
|
||||
[super viewWillDisappear:animated];
|
||||
[NSNotificationCenter.defaultCenter removeObserver:self
|
||||
name:UIApplicationWillEnterForegroundNotification
|
||||
object:nil];
|
||||
}
|
||||
|
||||
- (UIView *)mapView:(GMSMapView *)mapView markerInfoContents:(GMSMarker *)marker {
|
||||
// Show an info window with dynamic content - a simple background color animation.
|
||||
_infoView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow"]];
|
||||
UIView *infoView = _infoView;
|
||||
marker.tracksInfoWindowChanges = YES;
|
||||
UIColor *color = [UIColor colorWithHue:randf() saturation:1.f brightness:1.f alpha:1.0f];
|
||||
_infoView.backgroundColor = [UIColor clearColor];
|
||||
[UIView animateWithDuration:1.0
|
||||
delay:1.0
|
||||
options:UIViewAnimationOptionCurveLinear
|
||||
animations:^{
|
||||
infoView.backgroundColor = color;
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
[UIView animateWithDuration:1.0
|
||||
delay:0.0
|
||||
options:UIViewAnimationOptionCurveLinear
|
||||
animations:^{
|
||||
infoView.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
completion:^(BOOL finished2) {
|
||||
marker.tracksInfoWindowChanges = NO;
|
||||
}];
|
||||
}];
|
||||
|
||||
return _infoView;
|
||||
}
|
||||
|
||||
- (void)mapView:(GMSMapView *)mapView didCloseInfoWindowOfMarker:(GMSMarker *)marker {
|
||||
_infoView = nil;
|
||||
marker.tracksInfoWindowChanges = NO;
|
||||
}
|
||||
|
||||
- (void)addDefaultMarker {
|
||||
// Add a custom 'glow' marker with a pulsing blue shadow on Sydney.
|
||||
GMSMarker *sydneyMarker = [[GMSMarker alloc] init];
|
||||
sydneyMarker.title = @"Sydney!";
|
||||
sydneyMarker.iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"glow-marker"]];
|
||||
sydneyMarker.position = CLLocationCoordinate2DMake(-33.8683, 151.2086);
|
||||
sydneyMarker.iconView.contentMode = UIViewContentModeCenter;
|
||||
CGRect oldBound = sydneyMarker.iconView.bounds;
|
||||
CGRect bound = oldBound;
|
||||
bound.size.width *= 2;
|
||||
bound.size.height *= 2;
|
||||
sydneyMarker.iconView.bounds = bound;
|
||||
sydneyMarker.groundAnchor = CGPointMake(0.5, 0.75);
|
||||
sydneyMarker.infoWindowAnchor = CGPointMake(0.5, 0.25);
|
||||
UIView *sydneyGlow = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"glow-marker"]];
|
||||
sydneyGlow.layer.shadowColor = [UIColor blueColor].CGColor;
|
||||
sydneyGlow.layer.shadowOffset = CGSizeZero;
|
||||
sydneyGlow.layer.shadowRadius = 8.0;
|
||||
sydneyGlow.layer.shadowOpacity = 1.0;
|
||||
sydneyGlow.layer.opacity = 0.0;
|
||||
[sydneyMarker.iconView addSubview:sydneyGlow];
|
||||
sydneyGlow.center = CGPointMake(oldBound.size.width, oldBound.size.height);
|
||||
sydneyMarker.map = _mapView;
|
||||
[UIView animateWithDuration:1.0
|
||||
delay:0.0
|
||||
options:UIViewAnimationOptionCurveEaseInOut | UIViewKeyframeAnimationOptionAutoreverse |
|
||||
UIViewKeyframeAnimationOptionRepeat
|
||||
animations:^{
|
||||
sydneyGlow.layer.opacity = 1.0;
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
// If the animation is ever terminated, no need to keep tracking the view for changes.
|
||||
sydneyMarker.tracksViewChanges = NO;
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
26
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/BasicMapViewController.h
generated
Executable file
26
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/BasicMapViewController.h
generated
Executable file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface BasicMapViewController : UIViewController <GMSMapViewDelegate>
|
||||
|
||||
@end
|
||||
58
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/BasicMapViewController.m
generated
Executable file
58
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/BasicMapViewController.m
generated
Executable file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/BasicMapViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@implementation BasicMapViewController {
|
||||
UILabel *_statusLabel;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
// Seattle coordinates
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:47.6089945
|
||||
longitude:-122.3410462
|
||||
zoom:14];
|
||||
GMSMapView *view = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
view.delegate = self;
|
||||
self.view = view;
|
||||
|
||||
// Add status label, initially hidden.
|
||||
_statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 30)];
|
||||
_statusLabel.alpha = 0.0f;
|
||||
_statusLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
_statusLabel.backgroundColor = [UIColor blueColor];
|
||||
_statusLabel.textColor = [UIColor whiteColor];
|
||||
_statusLabel.textAlignment = NSTextAlignmentCenter;
|
||||
|
||||
[view addSubview:_statusLabel];
|
||||
}
|
||||
|
||||
- (void)mapViewDidStartTileRendering:(GMSMapView *)mapView {
|
||||
_statusLabel.alpha = 0.8f;
|
||||
_statusLabel.text = @"Rendering";
|
||||
}
|
||||
|
||||
- (void)mapViewDidFinishTileRendering:(GMSMapView *)mapView {
|
||||
_statusLabel.alpha = 0.0f;
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/CameraViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/CameraViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface CameraViewController : UIViewController
|
||||
|
||||
@end
|
||||
76
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/CameraViewController.m
generated
Executable file
76
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/CameraViewController.m
generated
Executable file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/CameraViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@implementation CameraViewController {
|
||||
GMSMapView *_mapView;
|
||||
NSTimer *_timer;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-37.809487
|
||||
longitude:144.965699
|
||||
zoom:20
|
||||
bearing:0
|
||||
viewingAngle:0];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
_mapView.settings.zoomGestures = NO;
|
||||
_mapView.settings.scrollGestures = NO;
|
||||
_mapView.settings.rotateGestures = NO;
|
||||
_mapView.settings.tiltGestures = NO;
|
||||
|
||||
self.view = _mapView;
|
||||
}
|
||||
|
||||
- (void)moveCamera:(NSTimer *)timer {
|
||||
GMSCameraPosition *camera = _mapView.camera;
|
||||
float zoom = fmaxf(camera.zoom - 0.1f, 17.5f);
|
||||
|
||||
GMSCameraPosition *newCamera =
|
||||
[[GMSCameraPosition alloc] initWithTarget:camera.target
|
||||
zoom:zoom
|
||||
bearing:camera.bearing + 10
|
||||
viewingAngle:camera.viewingAngle + 10];
|
||||
[_mapView animateToCameraPosition:newCamera];
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
[super viewDidAppear:animated];
|
||||
_timer = [NSTimer scheduledTimerWithTimeInterval:1.f / 30.f
|
||||
target:self
|
||||
selector:@selector(moveCamera:)
|
||||
userInfo:nil
|
||||
repeats:YES];
|
||||
}
|
||||
|
||||
- (void)viewDidDisappear:(BOOL)animated {
|
||||
[super viewDidDisappear:animated];
|
||||
[_timer invalidate];
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning {
|
||||
[super didReceiveMemoryWarning];
|
||||
[_timer invalidate];
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/CustomIndoorViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/CustomIndoorViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface CustomIndoorViewController : UIViewController
|
||||
|
||||
@end
|
||||
154
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/CustomIndoorViewController.m
generated
Executable file
154
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/CustomIndoorViewController.m
generated
Executable file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/CustomIndoorViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface CustomIndoorViewController () <GMSIndoorDisplayDelegate,
|
||||
UIPickerViewDelegate,
|
||||
UIPickerViewDataSource>
|
||||
|
||||
@end
|
||||
|
||||
@implementation CustomIndoorViewController {
|
||||
GMSMapView *_mapView;
|
||||
UIPickerView *_levelPickerView;
|
||||
NSArray *_levels;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:37.78318
|
||||
longitude:-122.403874
|
||||
zoom:18];
|
||||
|
||||
// Set backgroundColor, otherwise UIPickerView fades into the background
|
||||
self.view.backgroundColor = [UIColor grayColor];
|
||||
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
_mapView.settings.myLocationButton = NO;
|
||||
_mapView.settings.indoorPicker = NO; // We are implementing a custom level picker.
|
||||
|
||||
_mapView.indoorEnabled = YES; // Defaults to YES. Set to NO to hide indoor maps.
|
||||
_mapView.indoorDisplay.delegate = self;
|
||||
_mapView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[self.view addSubview:_mapView];
|
||||
|
||||
// This UIPickerView will be populated with the levels of the active building.
|
||||
_levelPickerView = [[UIPickerView alloc] init];
|
||||
_levelPickerView.delegate = self;
|
||||
_levelPickerView.dataSource = self;
|
||||
_levelPickerView.showsSelectionIndicator = YES;
|
||||
_levelPickerView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[self.view addSubview:_levelPickerView];
|
||||
|
||||
// The height of the UIPickerView, used below in the vertical constraint
|
||||
NSDictionary *metrics = @{@"height" : @180.0};
|
||||
NSDictionary *views = NSDictionaryOfVariableBindings(_mapView, _levelPickerView);
|
||||
|
||||
// Constraining the map to the full width of the display. The |_levelPickerView| is constrained
|
||||
// below with the NSLayoutFormatAlignAll*. See
|
||||
// http://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Articles/formatLanguage.html
|
||||
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[_mapView]|"
|
||||
options:0
|
||||
metrics:metrics
|
||||
views:views]];
|
||||
|
||||
// Constraining the _mapView and the _levelPickerView as siblings taking the full height of the
|
||||
// display, with _levelPickerView at 200 points high
|
||||
[self.view
|
||||
addConstraints:[NSLayoutConstraint
|
||||
constraintsWithVisualFormat:@"V:|[_mapView][_levelPickerView(height)]|"
|
||||
options:NSLayoutFormatAlignAllLeft |
|
||||
NSLayoutFormatAlignAllRight
|
||||
metrics:metrics
|
||||
views:views]];
|
||||
}
|
||||
|
||||
#pragma mark - GMSIndoorDisplayDelegate
|
||||
|
||||
- (void)didChangeActiveBuilding:(GMSIndoorBuilding *)building {
|
||||
// Everytime we change active building force the picker to re-display the labels.
|
||||
|
||||
NSMutableArray *levels = [NSMutableArray array];
|
||||
if (building.underground) {
|
||||
// If this building is completely underground, add a fake 'top' floor. This must be the 'boxed'
|
||||
// nil, [NSNull null], as NSArray/NSMutableArray cannot contain nils.
|
||||
[levels addObject:[NSNull null]];
|
||||
}
|
||||
[levels addObjectsFromArray:building.levels];
|
||||
_levels = [levels copy];
|
||||
|
||||
[_levelPickerView reloadAllComponents];
|
||||
[_levelPickerView selectRow:0 inComponent:0 animated:NO];
|
||||
|
||||
// UIPickerView insists on having some data; disable interaction if there's no levels.
|
||||
_levelPickerView.userInteractionEnabled = (_levels.count > 0);
|
||||
}
|
||||
|
||||
- (void)didChangeActiveLevel:(GMSIndoorLevel *)level {
|
||||
// On level change, sync our level picker's selection to the IndoorDisplay.
|
||||
if (level == nil) {
|
||||
level = (id)[NSNull null]; // box nil to NSNull for use in NSArray
|
||||
}
|
||||
NSUInteger index = [_levels indexOfObject:level];
|
||||
if (index != NSNotFound) {
|
||||
NSInteger currentlySelectedLevel = [_levelPickerView selectedRowInComponent:0];
|
||||
if ((NSInteger)index != currentlySelectedLevel) {
|
||||
[_levelPickerView selectRow:index inComponent:0 animated:NO];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - UIPickerViewDelegate
|
||||
|
||||
- (void)pickerView:(UIPickerView *)pickerView
|
||||
didSelectRow:(NSInteger)row
|
||||
inComponent:(NSInteger)component {
|
||||
// On user selection of a level in the picker, set the right level in IndoorDisplay
|
||||
id level = _levels[row];
|
||||
if (level == [NSNull null]) {
|
||||
level = nil; // unbox NSNull
|
||||
}
|
||||
[_mapView.indoorDisplay setActiveLevel:level];
|
||||
}
|
||||
|
||||
- (NSString *)pickerView:(UIPickerView *)pickerView
|
||||
titleForRow:(NSInteger)row
|
||||
forComponent:(NSInteger)component {
|
||||
id object = _levels[row];
|
||||
if (object == [NSNull null]) {
|
||||
return @"\u2014"; // use an em dash for 'above ground'
|
||||
}
|
||||
GMSIndoorLevel *level = object;
|
||||
return level.name;
|
||||
}
|
||||
|
||||
#pragma mark - UIPickerViewDataSource
|
||||
|
||||
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
|
||||
return 1;
|
||||
}
|
||||
|
||||
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component {
|
||||
return _levels.count;
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/CustomMarkersViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/CustomMarkersViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface CustomMarkersViewController : UIViewController
|
||||
|
||||
@end
|
||||
129
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/CustomMarkersViewController.m
generated
Executable file
129
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/CustomMarkersViewController.m
generated
Executable file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/CustomMarkersViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
static int kMarkerCount = 0;
|
||||
|
||||
// Returns a random value from 0-1.0f.
|
||||
static CGFloat randf() { return (((float)arc4random() / 0x100000000) * 1.0f); }
|
||||
|
||||
@implementation CustomMarkersViewController {
|
||||
GMSMapView *_mapView;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-37.81969
|
||||
longitude:144.966085
|
||||
zoom:4];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
[self addDefaultMarkers];
|
||||
|
||||
// Add a button which adds random markers to the map.
|
||||
UIBarButtonItem *addButton =
|
||||
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
|
||||
target:self
|
||||
action:@selector(didTapAdd)];
|
||||
addButton.accessibilityLabel = @"Add Markers";
|
||||
UIBarButtonItem *clearButton = [[UIBarButtonItem alloc] initWithTitle:@"Clear Markers"
|
||||
style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(didTapClear)];
|
||||
self.navigationItem.rightBarButtonItems = @[ addButton, clearButton ];
|
||||
|
||||
self.view = _mapView;
|
||||
|
||||
// Reset count on view load
|
||||
kMarkerCount = 0;
|
||||
}
|
||||
|
||||
- (void)addDefaultMarkers {
|
||||
// Add a custom 'glow' marker around Sydney.
|
||||
GMSMarker *sydneyMarker = [[GMSMarker alloc] init];
|
||||
sydneyMarker.title = @"Sydney!";
|
||||
sydneyMarker.icon = [UIImage imageNamed:@"glow-marker"];
|
||||
sydneyMarker.position = CLLocationCoordinate2DMake(-33.8683, 151.2086);
|
||||
sydneyMarker.map = _mapView;
|
||||
|
||||
// Add a custom 'arrow' marker pointing to Melbourne.
|
||||
GMSMarker *melbourneMarker = [[GMSMarker alloc] init];
|
||||
melbourneMarker.title = @"Melbourne!";
|
||||
melbourneMarker.icon = [UIImage imageNamed:@"arrow"];
|
||||
melbourneMarker.position = CLLocationCoordinate2DMake(-37.81969, 144.966085);
|
||||
melbourneMarker.map = _mapView;
|
||||
}
|
||||
|
||||
- (void)didTapAdd {
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
// Add a marker every 0.25 seconds for the next ten markers, randomly within the bounds of the
|
||||
// camera as it is at that point.
|
||||
double delayInSeconds = (i * 0.25);
|
||||
dispatch_time_t popTime =
|
||||
dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
|
||||
__typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf) {
|
||||
GMSVisibleRegion region = [strongSelf->_mapView.projection visibleRegion];
|
||||
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithRegion:region];
|
||||
[strongSelf addMarkerInBounds:bounds];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)addMarkerInBounds:(GMSCoordinateBounds *)bounds {
|
||||
CLLocationDegrees latitude =
|
||||
bounds.southWest.latitude + randf() * (bounds.northEast.latitude - bounds.southWest.latitude);
|
||||
|
||||
// If the visible region crosses the antimeridian (the right-most point is "smaller" than the
|
||||
// left-most point), adjust the longitude accordingly.
|
||||
BOOL offset = (bounds.northEast.longitude < bounds.southWest.longitude);
|
||||
CLLocationDegrees longitude =
|
||||
bounds.southWest.longitude +
|
||||
randf() * (bounds.northEast.longitude - bounds.southWest.longitude + (offset ? 360 : 0));
|
||||
if (longitude > 180.f) {
|
||||
longitude -= 360.f;
|
||||
}
|
||||
|
||||
UIColor *color = [UIColor colorWithHue:randf() saturation:1.f brightness:1.f alpha:1.0f];
|
||||
|
||||
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(latitude, longitude);
|
||||
GMSMarker *marker = [GMSMarker markerWithPosition:position];
|
||||
marker.title = [NSString stringWithFormat:@"Marker #%d", ++kMarkerCount];
|
||||
marker.appearAnimation = kGMSMarkerAnimationPop;
|
||||
marker.icon = [GMSMarker markerImageWithColor:color];
|
||||
|
||||
marker.rotation = (randf() - 0.5f) * 20; // rotate between -10 and +10 degrees
|
||||
|
||||
marker.map = _mapView;
|
||||
}
|
||||
|
||||
- (void)didTapClear {
|
||||
[_mapView clear];
|
||||
[self addDefaultMarkers];
|
||||
|
||||
// Reset count on clear
|
||||
kMarkerCount = 0;
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingBasicViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingBasicViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2022 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface DataDrivenStylingBasicViewController : UIViewController
|
||||
|
||||
@end
|
||||
271
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingBasicViewController.m
generated
Executable file
271
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingBasicViewController.m
generated
Executable file
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
* Copyright 2022 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingBasicViewController.h"
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Common/UIViewController+GMSModals.h"
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
// Put your Map ID in the string below. In the cloud console, configure the Map ID with a style that
|
||||
// enables the "Administrative Area Level 2" feature layer.
|
||||
static NSString *const kMapIDWithAdministrativeAreaLevel2 = @"";
|
||||
// Put your Map ID in the string below. In the cloud console, configure the Map ID with a style that
|
||||
// enables the "Postal Code" feature layer.
|
||||
static NSString *const kMapIDWithPostalCode = @"";
|
||||
// Put your Map ID in the string below. In the cloud console, configure the Map ID with a style that
|
||||
// enables the "Country" feature layer.
|
||||
static NSString *const kMapIDWithCountry = @"";
|
||||
|
||||
@interface DataDrivenStylingFeatureLayerConfig : NSObject
|
||||
|
||||
- (instancetype)initWithTitle:(NSString *)title
|
||||
type:(GMSFeatureType)type
|
||||
mapID:(NSString *)mapID
|
||||
highlightPlaceName:(NSString *)highlightPlaceName
|
||||
highlightPlaceID:(NSString *)highlightPlaceID;
|
||||
|
||||
@property(nonatomic, readonly) NSString *title;
|
||||
@property(nonatomic, readonly) GMSFeatureType type;
|
||||
@property(nonatomic, readwrite) NSString *mapID;
|
||||
@property(nonatomic, readonly) NSString *highlightPlaceName;
|
||||
@property(nonatomic, readonly) NSString *highlightPlaceID;
|
||||
|
||||
@end
|
||||
|
||||
@implementation DataDrivenStylingFeatureLayerConfig
|
||||
|
||||
- (instancetype)initWithTitle:(NSString *)title
|
||||
type:(GMSFeatureType)type
|
||||
mapID:(NSString *)mapID
|
||||
highlightPlaceName:(NSString *)highlightPlaceName
|
||||
highlightPlaceID:(NSString *)highlightPlaceID {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_title = title;
|
||||
_type = type;
|
||||
_mapID = mapID;
|
||||
_highlightPlaceName = highlightPlaceName;
|
||||
_highlightPlaceID = highlightPlaceID;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation DataDrivenStylingBasicViewController {
|
||||
NSArray<DataDrivenStylingFeatureLayerConfig *> *_configs;
|
||||
GMSMapView *_mapView;
|
||||
UISegmentedControl *_segmentedControl;
|
||||
UISwitch *_toggle;
|
||||
NSMutableArray<NSArray<UISlider *> *> *_sliderControls;
|
||||
GMSFeatureLayer *_layer;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
if ((self = [super init])) {
|
||||
_configs = @[
|
||||
[[DataDrivenStylingFeatureLayerConfig alloc]
|
||||
initWithTitle:@"Administrative Area Level 2"
|
||||
type:GMSFeatureTypeAdministrativeAreaLevel2
|
||||
mapID:kMapIDWithAdministrativeAreaLevel2
|
||||
/** Place name and ID for Nye County, Nevada. The area will be highlighted. */
|
||||
highlightPlaceName:@"Nye County, NV"
|
||||
highlightPlaceID:@"ChIJJcLL_DeWvoARQyqHFcY2se4"],
|
||||
[[DataDrivenStylingFeatureLayerConfig alloc]
|
||||
initWithTitle:@"Postal Code"
|
||||
type:GMSFeatureTypePostalCode
|
||||
mapID:kMapIDWithPostalCode
|
||||
/** Place name and ID for Zipcode 89049. The area will be highlighted. */
|
||||
highlightPlaceName:@"89049"
|
||||
highlightPlaceID:@"ChIJCY_aZdEwuoARZDbZn-snj68"],
|
||||
[[DataDrivenStylingFeatureLayerConfig alloc]
|
||||
initWithTitle:@"Country"
|
||||
type:GMSFeatureTypeCountry
|
||||
mapID:kMapIDWithCountry
|
||||
/** Place name and ID for the country Senegal. The area will be highlighted. */
|
||||
highlightPlaceName:@"Senegal"
|
||||
highlightPlaceID:@"ChIJcbvFs_VywQ4RQFlhmVClRlo"],
|
||||
];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (DataDrivenStylingFeatureLayerConfig *)activeConfig {
|
||||
if (_segmentedControl.selectedSegmentIndex == UISegmentedControlNoSegment) {
|
||||
return nil;
|
||||
}
|
||||
return _configs[_segmentedControl.selectedSegmentIndex];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
_segmentedControl = [[UISegmentedControl alloc] initWithItems:[_configs valueForKey:@"title"]];
|
||||
[_segmentedControl addTarget:self
|
||||
action:@selector(changeMapType:)
|
||||
forControlEvents:UIControlEventValueChanged];
|
||||
|
||||
_toggle = [[UISwitch alloc] initWithFrame:CGRectZero];
|
||||
[_toggle addTarget:self
|
||||
action:@selector(activateFeatureLayer:)
|
||||
forControlEvents:UIControlEventValueChanged];
|
||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:_toggle];
|
||||
self.navigationItem.titleView = _segmentedControl;
|
||||
|
||||
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
label.text = @"Select a feature type";
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
self.view = label;
|
||||
}
|
||||
|
||||
- (void)changeMapType:(id)sender {
|
||||
if (_segmentedControl.selectedSegmentIndex == UISegmentedControlNoSegment) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Camera position that roughly covers the contiguous United States.
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:38.590240
|
||||
longitude:-95.712891
|
||||
zoom:4];
|
||||
DataDrivenStylingFeatureLayerConfig *config = self.activeConfig;
|
||||
if (!config.mapID.length) {
|
||||
[self gms_promptForMapIDWithDescription:[NSString stringWithFormat:@"with %@ layer enabled",
|
||||
config.title]
|
||||
handler:^(NSString *mapID) {
|
||||
if (mapID.length) {
|
||||
config.mapID = mapID;
|
||||
} else {
|
||||
_segmentedControl.selectedSegmentIndex =
|
||||
UISegmentedControlNoSegment;
|
||||
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
label.text = @"A Map ID is required";
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
self.view = label;
|
||||
}
|
||||
[self changeMapType:nil];
|
||||
}];
|
||||
return;
|
||||
}
|
||||
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero
|
||||
mapID:[GMSMapID mapIDWithIdentifier:config.mapID]
|
||||
camera:camera];
|
||||
self.view = _mapView;
|
||||
[self setUpStyleControls];
|
||||
[_toggle setOn:NO animated:NO];
|
||||
_layer = [_mapView featureLayerOfFeatureType:self.activeConfig.type];
|
||||
}
|
||||
|
||||
- (UISlider *)addSliderInParent:(UIStackView *)parent
|
||||
label:(NSString *)label
|
||||
initialValue:(float)value {
|
||||
UILabel *uiLabel = [[UILabel alloc] init];
|
||||
uiLabel.text = label;
|
||||
uiLabel.font = [uiLabel.font fontWithSize:9];
|
||||
[parent addArrangedSubview:uiLabel];
|
||||
|
||||
UISlider *slider = [[UISlider alloc] init];
|
||||
slider.value = value;
|
||||
[parent addArrangedSubview:slider];
|
||||
[slider addTarget:self
|
||||
action:@selector(activateFeatureLayer:)
|
||||
forControlEvents:UIControlEventValueChanged];
|
||||
return slider;
|
||||
}
|
||||
|
||||
- (UIStackView *)setUpStyleControlForTitle:(NSString *)title index:(NSUInteger)index {
|
||||
UIStackView *stackView = [[UIStackView alloc] init];
|
||||
stackView.axis = UILayoutConstraintAxisVertical;
|
||||
stackView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
stackView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.5];
|
||||
|
||||
// The first style control is for the single area being highlighted while the second one is the
|
||||
// base style for all other areas.
|
||||
BOOL isBaseStyle = index > 0;
|
||||
_sliderControls[index] = @[
|
||||
[self addSliderInParent:stackView label:@"Fill color" initialValue:isBaseStyle ? 0.5 : 0.75],
|
||||
[self addSliderInParent:stackView label:@"Stroke color" initialValue:isBaseStyle ? 0 : 0.25],
|
||||
[self addSliderInParent:stackView label:@"Stroke width" initialValue:isBaseStyle ? 0.1 : 0.2]
|
||||
];
|
||||
|
||||
UILabel *label = [[UILabel alloc] init];
|
||||
label.text = title;
|
||||
label.font = [label.font fontWithSize:10];
|
||||
label.textAlignment = NSTextAlignmentCenter;
|
||||
[stackView addArrangedSubview:label];
|
||||
|
||||
return stackView;
|
||||
}
|
||||
|
||||
- (void)setUpStyleControls {
|
||||
_sliderControls = [NSMutableArray arrayWithCapacity:2];
|
||||
UIStackView *leftStackView = [self setUpStyleControlForTitle:self.activeConfig.highlightPlaceName
|
||||
index:0];
|
||||
UIStackView *rightStackView = [self setUpStyleControlForTitle:@"Others" index:1];
|
||||
|
||||
[self.view addSubview:leftStackView];
|
||||
[self.view addSubview:rightStackView];
|
||||
|
||||
[NSLayoutConstraint activateConstraints:@[
|
||||
[leftStackView.widthAnchor constraintEqualToAnchor:rightStackView.widthAnchor],
|
||||
[leftStackView.trailingAnchor constraintEqualToAnchor:rightStackView.leadingAnchor],
|
||||
[leftStackView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
|
||||
[rightStackView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
|
||||
[leftStackView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor],
|
||||
[rightStackView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor]
|
||||
]];
|
||||
}
|
||||
|
||||
+ (GMSFeatureStyle *)styleFromControls:(NSArray<UISlider *> *)controls {
|
||||
UIColor *fillColor = [UIColor colorWithHue:controls[0].value
|
||||
saturation:1
|
||||
brightness:0.5
|
||||
alpha:0.5];
|
||||
UIColor *strokeColor = [UIColor colorWithHue:controls[1].value
|
||||
saturation:1
|
||||
brightness:0.5
|
||||
alpha:1];
|
||||
CGFloat strokeWidth = controls[2].value * 15;
|
||||
return [GMSFeatureStyle styleWithFillColor:fillColor
|
||||
strokeColor:strokeColor
|
||||
strokeWidth:strokeWidth];
|
||||
}
|
||||
|
||||
- (void)activateFeatureLayer:(id *)sender {
|
||||
DataDrivenStylingFeatureLayerConfig *config = self.activeConfig;
|
||||
NSString *placeID = config.highlightPlaceID;
|
||||
if (_toggle.on) {
|
||||
if (!_layer.isAvailable) {
|
||||
[self gms_showToastWithMessage:[NSString
|
||||
stringWithFormat:@"Feature layer %@ is not available on "
|
||||
@"map ID %@; see debug log for details",
|
||||
config.title, config.mapID]];
|
||||
}
|
||||
GMSFeatureStyle *specialStyle = [[self class] styleFromControls:_sliderControls[0]];
|
||||
GMSFeatureStyle *style = [[self class] styleFromControls:_sliderControls[1]];
|
||||
_layer.style = ^(GMSPlaceFeature *feature) {
|
||||
return [placeID isEqualToString:((GMSPlaceFeature *)feature).placeID] ? specialStyle : style;
|
||||
};
|
||||
} else {
|
||||
_layer.style = nil;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
26
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingEventsViewController.h
generated
Executable file
26
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingEventsViewController.h
generated
Executable file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2022 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface DataDrivenStylingEventsViewController
|
||||
: UIViewController <GMSMapViewDelegate, UITableViewDelegate, UITableViewDataSource>
|
||||
@end
|
||||
309
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingEventsViewController.m
generated
Executable file
309
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingEventsViewController.m
generated
Executable file
@@ -0,0 +1,309 @@
|
||||
/*
|
||||
* Copyright 2022 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingEventsViewController.h"
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Common/UIViewController+GMSModals.h"
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
// Put your Map ID in the string below. In the cloud console, configure the Map ID with a style that
|
||||
// enables all data-driven styling feature layers.
|
||||
static NSString *const kMapIDWithMultipleLayers = @"";
|
||||
|
||||
static const double kSeattleLatitudeDegrees = 47.61;
|
||||
static const double kSeattleLongitudeDegrees = -122.34;
|
||||
static const double kZoom = 10;
|
||||
|
||||
static NSString *const kCellIdentifierForLayerToggle = @"kCellIdentifierForLayerToggle";
|
||||
static NSString *const kCellIdentifierForSelectedFeatureName =
|
||||
@"kCellIdentifierForSelectedFeatureName";
|
||||
|
||||
typedef GMSFeatureStyle * (^GMSPlaceFeatureStyleBlock)(GMSPlaceFeature *);
|
||||
|
||||
@interface FeatureLayerState : NSObject
|
||||
|
||||
- (instancetype)initWithType:(GMSFeatureType)featureType
|
||||
label:(NSString *)label
|
||||
color:(UIColor *)color;
|
||||
|
||||
- (NSInteger)selectedFeatureCount;
|
||||
- (NSString *)selectedFeatureNameAtIndex:(NSInteger)index;
|
||||
|
||||
- (void)unselectFeatureAtIndex:(NSInteger)index;
|
||||
- (void)toggleSelectionOfFeatures:(NSArray<GMSPlaceFeature *> *)features
|
||||
textUpdateHandler:(void (^)())handler;
|
||||
|
||||
- (GMSPlaceFeatureStyleBlock)makeStyleBlock;
|
||||
|
||||
@property(nonatomic, readonly) GMSFeatureType type;
|
||||
@property(nonatomic, readonly, nonnull) NSString *label;
|
||||
@property(nonatomic, readonly, nonnull) UIColor *color;
|
||||
@property(nonatomic, readwrite, nullable) GMSFeatureLayer *layer;
|
||||
|
||||
@end
|
||||
|
||||
@implementation FeatureLayerState {
|
||||
NSMutableDictionary<NSString *, NSString *> *_featureNamesByPlaceID;
|
||||
NSMutableArray<NSString *> *_selectedFeaturePlaceIDs;
|
||||
}
|
||||
|
||||
- (instancetype)initWithType:(GMSFeatureType)featureType
|
||||
label:(NSString *)label
|
||||
color:(UIColor *)color {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_type = featureType;
|
||||
_label = label;
|
||||
_color = color;
|
||||
_featureNamesByPlaceID = [NSMutableDictionary dictionary];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSInteger)selectedFeatureCount {
|
||||
return _selectedFeaturePlaceIDs.count;
|
||||
}
|
||||
|
||||
- (NSString *)selectedFeatureNameAtIndex:(NSInteger)index {
|
||||
return _featureNamesByPlaceID[_selectedFeaturePlaceIDs[index]];
|
||||
}
|
||||
|
||||
- (void)unselectFeatureAtIndex:(NSInteger)index {
|
||||
NSString *placeID = _selectedFeaturePlaceIDs[index];
|
||||
[_featureNamesByPlaceID removeObjectForKey:placeID];
|
||||
[_selectedFeaturePlaceIDs removeObjectAtIndex:index];
|
||||
}
|
||||
|
||||
- (void)toggleSelectionOfFeatures:(NSArray<GMSPlaceFeature *> *)features
|
||||
textUpdateHandler:(void (^)())handler {
|
||||
for (id<GMSFeature> feature in features) {
|
||||
// For these feature types, feature instances would certainly be GMSPlaceFeature.
|
||||
GMSPlaceFeature *place = (GMSPlaceFeature *)feature;
|
||||
NSString *placeID = place.placeID;
|
||||
if (_featureNamesByPlaceID[placeID]) {
|
||||
[_featureNamesByPlaceID removeObjectForKey:placeID];
|
||||
} else {
|
||||
_featureNamesByPlaceID[placeID] = [NSString stringWithFormat:@"[Place %@]", placeID];
|
||||
}
|
||||
}
|
||||
_selectedFeaturePlaceIDs =
|
||||
[[_featureNamesByPlaceID keysSortedByValueUsingSelector:@selector(compare:)] mutableCopy];
|
||||
}
|
||||
|
||||
- (GMSPlaceFeatureStyleBlock)makeStyleBlock {
|
||||
GMSFeatureStyle *nonSelectedStyle =
|
||||
[GMSFeatureStyle styleWithFillColor:[self.color colorWithAlphaComponent:0.25]
|
||||
strokeColor:self.color
|
||||
strokeWidth:1.5];
|
||||
GMSFeatureStyle *selectedStyle =
|
||||
[GMSFeatureStyle styleWithFillColor:[self.color colorWithAlphaComponent:0.5]
|
||||
strokeColor:self.color
|
||||
strokeWidth:3];
|
||||
return ^(GMSPlaceFeature *feature) {
|
||||
NSString *placeID = (((GMSPlaceFeature *)feature).placeID);
|
||||
return _featureNamesByPlaceID[placeID] ? selectedStyle : nonSelectedStyle;
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation DataDrivenStylingEventsViewController {
|
||||
NSArray<FeatureLayerState *> *_featureLayerStates;
|
||||
UITableView *_tableView;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_featureLayerStates = @[
|
||||
[[FeatureLayerState alloc] initWithType:GMSFeatureTypeCountry
|
||||
label:@"Country"
|
||||
color:[UIColor purpleColor]],
|
||||
[[FeatureLayerState alloc] initWithType:GMSFeatureTypeAdministrativeAreaLevel1
|
||||
label:@"Administrative Area Level 1"
|
||||
color:[UIColor orangeColor]],
|
||||
[[FeatureLayerState alloc] initWithType:GMSFeatureTypeAdministrativeAreaLevel2
|
||||
label:@"Administrative Area Level 2"
|
||||
color:[UIColor blueColor]],
|
||||
[[FeatureLayerState alloc] initWithType:GMSFeatureTypeLocality
|
||||
label:@"Locality"
|
||||
color:[UIColor redColor]],
|
||||
[[FeatureLayerState alloc] initWithType:GMSFeatureTypePostalCode
|
||||
label:@"Postal Code"
|
||||
color:[UIColor brownColor]],
|
||||
[[FeatureLayerState alloc] initWithType:GMSFeatureTypeSchoolDistrict
|
||||
label:@"School District"
|
||||
color:[UIColor cyanColor]],
|
||||
];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
if (kMapIDWithMultipleLayers.length) {
|
||||
[self setUpMapWithMapID:kMapIDWithMultipleLayers];
|
||||
return;
|
||||
}
|
||||
|
||||
[self gms_promptForMapIDWithDescription:@"with all data-driven styling layers enabled"
|
||||
handler:^(NSString *mapID) {
|
||||
[self setUpMapWithMapID:mapID];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setUpMapWithMapID:(NSString *)mapIDString {
|
||||
if (!mapIDString.length) {
|
||||
UILabel *text = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
text.text = @"A Map ID is required";
|
||||
text.textAlignment = NSTextAlignmentCenter;
|
||||
self.view = text;
|
||||
return;
|
||||
}
|
||||
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:kSeattleLatitudeDegrees
|
||||
longitude:kSeattleLongitudeDegrees
|
||||
zoom:kZoom];
|
||||
GMSMapID *mapID = [GMSMapID mapIDWithIdentifier:mapIDString];
|
||||
GMSMapView *_mapView = [GMSMapView mapWithFrame:CGRectZero mapID:mapID camera:camera];
|
||||
_mapView.delegate = self;
|
||||
self.view = _mapView;
|
||||
|
||||
_tableView = [[UITableView alloc] init];
|
||||
_tableView.dataSource = self;
|
||||
_tableView.delegate = self;
|
||||
_tableView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
_tableView.backgroundView = nil;
|
||||
_tableView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:0.75];
|
||||
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
_tableView.contentInset = UIEdgeInsetsMake(0, -10, 0, -10);
|
||||
[self.view addSubview:_tableView];
|
||||
[NSLayoutConstraint activateConstraints:@[
|
||||
[_tableView.leadingAnchor constraintEqualToAnchor:self.view.safeAreaLayoutGuide.trailingAnchor
|
||||
constant:-120],
|
||||
[_tableView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
|
||||
[_tableView.topAnchor constraintEqualToAnchor:self.view.topAnchor],
|
||||
[_tableView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor]
|
||||
]];
|
||||
}
|
||||
|
||||
#pragma mark UITableViewDataSource
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
// Toggle buttons (1), then selected feature list of each feature layer.
|
||||
return 1 + [_featureLayerStates count];
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
if (section == 0) {
|
||||
// The first section is for the toggle buttons for each layer.
|
||||
return [_featureLayerStates count];
|
||||
}
|
||||
// Count of selected features in the corresponding feature layer.
|
||||
return _featureLayerStates[section - 1].selectedFeatureCount;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView
|
||||
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
BOOL isToggleControl = indexPath.section == 0;
|
||||
NSString *cellIdentifier =
|
||||
isToggleControl ? kCellIdentifierForLayerToggle : kCellIdentifierForSelectedFeatureName;
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
|
||||
if (cell == nil) {
|
||||
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
|
||||
reuseIdentifier:cellIdentifier];
|
||||
cell.backgroundColor = [UIColor clearColor];
|
||||
}
|
||||
UILabel *textLabel = cell.textLabel;
|
||||
if (isToggleControl) {
|
||||
FeatureLayerState *featureLayerState = _featureLayerStates[indexPath.row];
|
||||
textLabel.text = [NSString stringWithFormat:@"%@ %@", (featureLayerState.layer ? @"☑" : @"☐"),
|
||||
featureLayerState.label];
|
||||
textLabel.font = [textLabel.font fontWithSize:14];
|
||||
textLabel.textColor =
|
||||
[featureLayerState.color colorWithAlphaComponent:(featureLayerState.layer ? 1 : 0.75)];
|
||||
} else {
|
||||
FeatureLayerState *featureLayerState = _featureLayerStates[indexPath.section - 1];
|
||||
textLabel.text = [featureLayerState selectedFeatureNameAtIndex:indexPath.row];
|
||||
textLabel.font = [textLabel.font fontWithSize:12];
|
||||
textLabel.textColor = featureLayerState.color;
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
#pragma mark UITableViewDelegate
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
return (indexPath.section == 0) ? 36 : 24;
|
||||
}
|
||||
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
if (indexPath.section == 0) {
|
||||
// Toggle a layer on/off.
|
||||
FeatureLayerState *state = _featureLayerStates[indexPath.row];
|
||||
if (state.layer) {
|
||||
state.layer.style = nil;
|
||||
state.layer = nil;
|
||||
} else {
|
||||
state.layer = [(GMSMapView *)(self.view) featureLayerOfFeatureType:state.type];
|
||||
state.layer.style = [state makeStyleBlock];
|
||||
if (!state.layer.isAvailable) {
|
||||
[self gms_showToastWithMessage:[NSString
|
||||
stringWithFormat:@"Feature layer %@ is not available; "
|
||||
@"see debug log for details",
|
||||
state.label]];
|
||||
}
|
||||
}
|
||||
[_tableView reloadRowsAtIndexPaths:@[ indexPath ] withRowAnimation:UITableViewRowAnimationNone];
|
||||
} else {
|
||||
FeatureLayerState *state = _featureLayerStates[indexPath.section - 1];
|
||||
[state unselectFeatureAtIndex:indexPath.row];
|
||||
state.layer.style = [state makeStyleBlock];
|
||||
[_tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section]
|
||||
withRowAnimation:UITableViewRowAnimationNone];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark GMSMapViewDelegate
|
||||
|
||||
- (void)mapView:(GMSMapView *)mapView
|
||||
didTapFeatures:(NSArray<id<GMSFeature>> *)features
|
||||
inFeatureLayer:(GMSFeatureLayer *)featureLayer
|
||||
atLocation:(CLLocationCoordinate2D)location {
|
||||
NSUInteger index = [_featureLayerStates
|
||||
indexOfObjectPassingTest:^BOOL(FeatureLayerState *state, NSUInteger idx, BOOL *stop) {
|
||||
return state.layer == featureLayer;
|
||||
}];
|
||||
if (index == NSNotFound) {
|
||||
return;
|
||||
}
|
||||
|
||||
FeatureLayerState *state = _featureLayerStates[index];
|
||||
void (^reloadRows)() = ^{
|
||||
[_tableView reloadSections:[NSIndexSet indexSetWithIndex:(1 + index)]
|
||||
withRowAnimation:UITableViewRowAnimationNone];
|
||||
};
|
||||
[state toggleSelectionOfFeatures:features textUpdateHandler:reloadRows];
|
||||
state.layer.style = [state makeStyleBlock];
|
||||
|
||||
reloadRows();
|
||||
}
|
||||
|
||||
@end
|
||||
23
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingSearchViewController.h
generated
Executable file
23
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingSearchViewController.h
generated
Executable file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2023 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
/**
|
||||
* ViewController to display multiple data-driven styling layers at the same time and handle events.
|
||||
*/
|
||||
@interface DataDrivenStylingSearchViewController : UIViewController
|
||||
|
||||
@end
|
||||
485
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingSearchViewController.m
generated
Executable file
485
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingSearchViewController.m
generated
Executable file
@@ -0,0 +1,485 @@
|
||||
/*
|
||||
* Copyright 2023 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingSearchViewController.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Common/GMSNotCapturingTouchesTableView.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Common/UIViewController+GMSModals.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/SDKDemoAPIKey.h"
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// Put your Map ID in the string below. In the cloud console, configure the Map ID with a style that
|
||||
// enables the "Administrative Area Level 2" feature layer.
|
||||
static NSString *const kMapIDWithAdmin2 = @"";
|
||||
|
||||
static NSArray<NSString *> *GetInitialSearches(void) {
|
||||
return @[ @"Nye County", @"San Bernardino County", @"Juab County", @"Crook County" ];
|
||||
}
|
||||
|
||||
// This demo uses Text Search feature from Places API. The API must be enabled from Cloud Console.
|
||||
// See https://developers.google.com/maps/documentation/places/web-service/search-textual for
|
||||
// details.
|
||||
static NSURLRequest *BuildSearchRequestForPlaceName(NSString *placeName) {
|
||||
// NSURL initializer only returns nil when the URL string is malformed, but it is a known valid
|
||||
// string literal here.
|
||||
NSURL *URL =
|
||||
(NSURL *_Nonnull)[NSURL URLWithString:@"https://places.googleapis.com/v1/places:searchText"];
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
|
||||
request.HTTPMethod = @"POST";
|
||||
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
|
||||
[request setValue:kAPIKey forHTTPHeaderField:@"X-Goog-Api-Key"];
|
||||
[request setValue:@"places.id" forHTTPHeaderField:@"X-Goog-FieldMask"];
|
||||
[request setValue:[[NSBundle mainBundle] bundleIdentifier]
|
||||
forHTTPHeaderField:@"X-Ios-Bundle-Identifier"];
|
||||
NSDictionary<NSString *, NSString *> *requestBody = @{
|
||||
@"textQuery" : placeName,
|
||||
@"includedType" : @"administrative_area_level_2",
|
||||
@"languageCode" : @"en"
|
||||
};
|
||||
request.HTTPBody = [NSJSONSerialization dataWithJSONObject:requestBody
|
||||
options:(NSJSONWritingOptions)0
|
||||
error:nil];
|
||||
return request;
|
||||
}
|
||||
|
||||
static NSString *_Nullable ExtractPlaceIDFromSearchResponse(id JSONResponse) {
|
||||
if (![JSONResponse isKindOfClass:[NSDictionary class]]) {
|
||||
return nil;
|
||||
}
|
||||
id placesArray = ((NSDictionary *)JSONResponse)[@"places"];
|
||||
if (![placesArray isKindOfClass:[NSArray class]]) {
|
||||
return nil;
|
||||
}
|
||||
id place = placesArray[0];
|
||||
if (![place isKindOfClass:[NSDictionary class]]) {
|
||||
return nil;
|
||||
}
|
||||
NSString *ID = place[@"id"];
|
||||
if (![ID isKindOfClass:[NSString class]]) {
|
||||
return nil;
|
||||
}
|
||||
return ID;
|
||||
}
|
||||
|
||||
@interface GMSPlaceLookupController
|
||||
: NSObject <UITextFieldDelegate, UIColorPickerViewControllerDelegate>
|
||||
|
||||
@property(nonatomic, readonly) NSUInteger serial;
|
||||
@property(nonatomic, nullable) NSString *name;
|
||||
@property(nonatomic, nullable) UIColor *color;
|
||||
@property(nonatomic, readonly, nullable) NSString *placeID;
|
||||
|
||||
@property(nonatomic, readonly) UIView *view;
|
||||
|
||||
- (void)focusTextEdit;
|
||||
|
||||
@end
|
||||
|
||||
@interface DataDrivenStylingSearchViewController ()
|
||||
|
||||
@property(nonatomic, readonly) NSURLSession *URLSession;
|
||||
|
||||
- (void)removeFeature:(GMSPlaceLookupController *)feature;
|
||||
|
||||
- (void)reloadStyle;
|
||||
|
||||
@end
|
||||
|
||||
@implementation GMSPlaceLookupController {
|
||||
__weak DataDrivenStylingSearchViewController *_controller;
|
||||
|
||||
UITextField *_textField;
|
||||
UIButton *_colorSelectionButton;
|
||||
}
|
||||
|
||||
- (instancetype)initWithController:(DataDrivenStylingSearchViewController *)controller
|
||||
serial:(NSUInteger)serial {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_controller = controller;
|
||||
_serial = serial;
|
||||
|
||||
_textField = [[UITextField alloc] init];
|
||||
_textField.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
_textField.backgroundColor = [UIColor.whiteColor colorWithAlphaComponent:0.5];
|
||||
_textField.font = [_textField.font fontWithSize:12];
|
||||
_textField.delegate = self;
|
||||
|
||||
_colorSelectionButton = [[UIButton alloc] initWithFrame:CGRectZero];
|
||||
_colorSelectionButton.titleLabel.font = [_colorSelectionButton.titleLabel.font fontWithSize:12];
|
||||
[_colorSelectionButton setTitle:@"❓" forState:UIControlStateNormal];
|
||||
[_colorSelectionButton addTarget:self
|
||||
action:@selector(selectionButtonTapped:)
|
||||
forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
_textField.leftView = _colorSelectionButton;
|
||||
_textField.leftViewMode = UITextFieldViewModeAlways;
|
||||
|
||||
UIButton *clearButton = [[UIButton alloc] initWithFrame:CGRectZero];
|
||||
clearButton.titleLabel.font = [clearButton.titleLabel.font fontWithSize:12];
|
||||
[clearButton setTitle:@"🗑️" forState:UIControlStateNormal];
|
||||
[clearButton addTarget:self
|
||||
action:@selector(remove)
|
||||
forControlEvents:UIControlEventTouchUpInside];
|
||||
_textField.rightView = clearButton;
|
||||
_textField.rightViewMode = UITextFieldViewModeUnlessEditing;
|
||||
|
||||
_textField.clearButtonMode = UITextFieldViewModeWhileEditing;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (UIView *)view {
|
||||
return _textField;
|
||||
}
|
||||
|
||||
- (void)setPlaceID:(NSString *)placeID {
|
||||
_placeID = [placeID copy];
|
||||
[_colorSelectionButton setTitle:@"⬤" forState:UIControlStateNormal];
|
||||
[_controller reloadStyle];
|
||||
}
|
||||
|
||||
- (void)setName:(nullable NSString *)name {
|
||||
_name = [name copy];
|
||||
_textField.text = name;
|
||||
|
||||
if (!name.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
NSURLSessionDataTask *dataTask = [_controller.URLSession
|
||||
dataTaskWithRequest:BuildSearchRequestForPlaceName(name)
|
||||
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
|
||||
__weak __typeof__(self) strongSelf = weakSelf;
|
||||
if (!strongSelf) {
|
||||
return;
|
||||
}
|
||||
if (error != nil) {
|
||||
[strongSelf textSearchFailedWithError:error];
|
||||
return;
|
||||
}
|
||||
NSError *JSONError = nil;
|
||||
id deserialized = [NSJSONSerialization JSONObjectWithData:data
|
||||
options:(NSJSONReadingOptions)0
|
||||
error:&JSONError];
|
||||
if (JSONError != nil) {
|
||||
[strongSelf textSearchFailedWithError:JSONError];
|
||||
return;
|
||||
}
|
||||
NSString *ID = ExtractPlaceIDFromSearchResponse(deserialized);
|
||||
if (ID) {
|
||||
strongSelf.placeID = ID;
|
||||
} else {
|
||||
NSError *unrecognizedResponseError =
|
||||
[NSError errorWithDomain:NSStringFromClass([strongSelf class])
|
||||
code:-1
|
||||
userInfo:@{@"response" : deserialized}];
|
||||
[strongSelf textSearchFailedWithError:unrecognizedResponseError];
|
||||
}
|
||||
}];
|
||||
[dataTask resume];
|
||||
}
|
||||
|
||||
- (void)setColor:(nullable UIColor *)color {
|
||||
_color = color;
|
||||
[_colorSelectionButton setTitleColor:color forState:UIControlStateNormal];
|
||||
[_controller reloadStyle];
|
||||
}
|
||||
|
||||
- (void)focusTextEdit {
|
||||
[_textField becomeFirstResponder];
|
||||
}
|
||||
|
||||
- (void)remove {
|
||||
[_controller removeFeature:self];
|
||||
}
|
||||
|
||||
- (void)textSearchFailedWithError:(NSError *)error {
|
||||
[_colorSelectionButton setTitle:@"❗" forState:UIControlStateNormal];
|
||||
NSLog(@"Feature \"%@\" not found: %@", self.name, error);
|
||||
}
|
||||
|
||||
- (void)selectionButtonTapped:(UIButton *)sender {
|
||||
UIColorPickerViewController *selector = [[UIColorPickerViewController alloc] init];
|
||||
selector.selectedColor = _color ?: UIColor.whiteColor;
|
||||
selector.supportsAlpha = NO;
|
||||
selector.delegate = self;
|
||||
[_controller presentModalViewController:selector animated:YES];
|
||||
}
|
||||
|
||||
#pragma mark - UITextFieldDelegate
|
||||
|
||||
- (void)textFieldDidEndEditing:(UITextField *)textField {
|
||||
NSString *text = [textField.text
|
||||
stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceAndNewlineCharacterSet];
|
||||
if (!text.length) {
|
||||
[_colorSelectionButton setTitle:@"❓" forState:UIControlStateNormal];
|
||||
return;
|
||||
}
|
||||
if ([self.name isEqualToString:text]) {
|
||||
return;
|
||||
}
|
||||
[_colorSelectionButton setTitle:@"⏳" forState:UIControlStateNormal];
|
||||
self.name = text;
|
||||
}
|
||||
|
||||
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
|
||||
// Finishes editing when pressing Enter.
|
||||
[textField resignFirstResponder];
|
||||
return NO;
|
||||
}
|
||||
|
||||
#pragma mark - UIColorPickerViewControllerDelegate
|
||||
|
||||
- (void)colorPickerViewControllerDidFinish:(UIColorPickerViewController *)viewController {
|
||||
self.color = viewController.selectedColor;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation DataDrivenStylingSearchViewController {
|
||||
GMSMapView *_mapView;
|
||||
UITableViewDiffableDataSource *_dataSource;
|
||||
UITableView *_tableView;
|
||||
|
||||
NSUInteger _placeSerial;
|
||||
|
||||
NSMutableDictionary<NSNumber *, GMSPlaceLookupController *> *_places;
|
||||
NSDictionary<NSString *, UIColor *> *_computedColorMapping;
|
||||
}
|
||||
|
||||
- (instancetype)init {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_places = [NSMutableDictionary dictionary];
|
||||
_URLSession = [NSURLSession
|
||||
sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]
|
||||
delegate:nil
|
||||
delegateQueue:[NSOperationQueue mainQueue]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
if (kMapIDWithAdmin2.length) {
|
||||
[self setUpMapWithMapID:kMapIDWithAdmin2];
|
||||
return;
|
||||
}
|
||||
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
[self gms_promptForMapIDWithDescription:@"with Administrative Area Level 2 layer enabled"
|
||||
handler:^(NSString *mapID) {
|
||||
[weakSelf setUpMapWithMapID:mapID];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setUpMapWithMapID:(NSString *)mapIDString {
|
||||
if (!mapIDString.length) {
|
||||
UILabel *text = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
text.text = @"A Map ID is required";
|
||||
text.textAlignment = NSTextAlignmentCenter;
|
||||
self.view = text;
|
||||
return;
|
||||
}
|
||||
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:40 longitude:-117.5 zoom:5.5];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero
|
||||
mapID:[GMSMapID mapIDWithIdentifier:mapIDString]
|
||||
camera:camera];
|
||||
[self.view addSubview:_mapView];
|
||||
_mapView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[NSLayoutConstraint activateConstraints:@[
|
||||
[_mapView.topAnchor constraintEqualToAnchor:self.view.topAnchor],
|
||||
[_mapView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
|
||||
[_mapView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
|
||||
[_mapView.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor],
|
||||
]];
|
||||
|
||||
NSString *cellIdentifier = NSStringFromClass([self class]);
|
||||
_tableView = [[GMSNotCapturingTouchesTableView alloc] initWithFrame:CGRectZero
|
||||
style:UITableViewStylePlain];
|
||||
[_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifier];
|
||||
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
||||
_tableView.rowHeight = 28;
|
||||
_tableView.backgroundView = nil;
|
||||
_tableView.backgroundColor = UIColor.clearColor;
|
||||
|
||||
NSMutableDictionary<NSNumber *, GMSPlaceLookupController *> *places = _places;
|
||||
_dataSource = [[UITableViewDiffableDataSource alloc]
|
||||
initWithTableView:_tableView
|
||||
cellProvider:^UITableViewCell *(UITableView *tableView, NSIndexPath *indexPath,
|
||||
NSNumber *itemIdentifier) {
|
||||
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier
|
||||
forIndexPath:indexPath];
|
||||
[cell.contentView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
||||
UIView *view = places[itemIdentifier].view;
|
||||
[cell.contentView addSubview:view];
|
||||
cell.backgroundColor = [UIColor clearColor];
|
||||
[NSLayoutConstraint activateConstraints:@[
|
||||
[cell.contentView.topAnchor constraintEqualToAnchor:view.topAnchor],
|
||||
[cell.contentView.leadingAnchor constraintEqualToAnchor:view.leadingAnchor],
|
||||
[cell.contentView.trailingAnchor constraintEqualToAnchor:view.trailingAnchor],
|
||||
[cell.contentView.bottomAnchor constraintEqualToAnchor:view.bottomAnchor]
|
||||
]];
|
||||
|
||||
return cell;
|
||||
}];
|
||||
_tableView.dataSource = _dataSource;
|
||||
_tableView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[self.view addSubview:_tableView];
|
||||
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
UIAction *addAction = [UIAction actionWithTitle:@"+"
|
||||
image:nil
|
||||
identifier:nil
|
||||
handler:^(UIAction *action) {
|
||||
[weakSelf addButtonTapped];
|
||||
}];
|
||||
self.navigationItem.rightBarButtonItem =
|
||||
[[UIBarButtonItem alloc] initWithPrimaryAction:addAction];
|
||||
|
||||
[NSLayoutConstraint activateConstraints:@[
|
||||
[_tableView.topAnchor constraintEqualToAnchor:self.view.topAnchor],
|
||||
[_tableView.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
|
||||
[_tableView.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
|
||||
[_tableView.heightAnchor constraintEqualToAnchor:self.view.heightAnchor multiplier:0.5]
|
||||
]];
|
||||
|
||||
NSArray<NSString *> *initialSearches = GetInitialSearches();
|
||||
NSMutableArray<NSNumber *> *identifiers =
|
||||
[NSMutableArray arrayWithCapacity:initialSearches.count];
|
||||
for (NSString *search in initialSearches) {
|
||||
[identifiers addObject:@([self addFeatureWithText:search])];
|
||||
}
|
||||
NSDiffableDataSourceSnapshot *diff = [[NSDiffableDataSourceSnapshot alloc] init];
|
||||
[diff appendSectionsWithIdentifiers:@[ @0 ]];
|
||||
[diff appendItemsWithIdentifiers:identifiers];
|
||||
[_dataSource applySnapshot:diff animatingDifferences:NO];
|
||||
}
|
||||
|
||||
- (void)addButtonTapped {
|
||||
NSNumber *itemIdentifier = @([self addFeatureWithText:nil]);
|
||||
GMSPlaceLookupController *lookup = _places[itemIdentifier];
|
||||
|
||||
NSDiffableDataSourceSnapshot *diff = [_dataSource snapshot];
|
||||
[diff appendItemsWithIdentifiers:@[ itemIdentifier ]];
|
||||
[_dataSource applySnapshot:diff animatingDifferences:NO];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[lookup focusTextEdit];
|
||||
});
|
||||
}
|
||||
|
||||
- (CGFloat)nextColorHue {
|
||||
NSMutableArray<NSNumber *> *hueValues = [NSMutableArray arrayWithCapacity:_places.count];
|
||||
for (GMSPlaceLookupController *config in _places.objectEnumerator) {
|
||||
CGFloat hueValue = 0.f;
|
||||
if ([config.color getHue:&hueValue saturation:nil brightness:nil alpha:nil]) {
|
||||
if (hueValue > 1 || hueValue < 0) {
|
||||
continue;
|
||||
}
|
||||
[hueValues addObject:@(hueValue)];
|
||||
}
|
||||
}
|
||||
float candidateHue = hueValues.firstObject.floatValue - 0.5f;
|
||||
if (hueValues.count > 1) {
|
||||
[hueValues sortUsingSelector:@selector(compare:)];
|
||||
CGFloat endOfLargestGap = hueValues.firstObject.floatValue;
|
||||
CGFloat largestGap = 1 + endOfLargestGap - hueValues.lastObject.floatValue;
|
||||
for (NSUInteger i = 1; i < hueValues.count; i++) {
|
||||
CGFloat gap = hueValues[i].floatValue - hueValues[i - 1].floatValue;
|
||||
if (gap > largestGap) {
|
||||
endOfLargestGap = hueValues[i].floatValue;
|
||||
largestGap = gap;
|
||||
}
|
||||
}
|
||||
candidateHue = endOfLargestGap - largestGap / 2;
|
||||
}
|
||||
if (candidateHue < 0) {
|
||||
candidateHue += 1.f;
|
||||
}
|
||||
return candidateHue;
|
||||
}
|
||||
|
||||
- (NSUInteger)addFeatureWithText:(nullable NSString *)text {
|
||||
NSUInteger itemIdentifier = ++_placeSerial;
|
||||
|
||||
GMSPlaceLookupController *featureConfig =
|
||||
[[GMSPlaceLookupController alloc] initWithController:self serial:itemIdentifier];
|
||||
|
||||
featureConfig.color = [UIColor colorWithHue:[self nextColorHue]
|
||||
saturation:1
|
||||
brightness:0.75
|
||||
alpha:1];
|
||||
featureConfig.name = text;
|
||||
_places[@(itemIdentifier)] = featureConfig;
|
||||
|
||||
return itemIdentifier;
|
||||
}
|
||||
|
||||
- (void)removeFeature:(GMSPlaceLookupController *)feature {
|
||||
if (_places.count == 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSDiffableDataSourceSnapshot *diff = [_dataSource snapshot];
|
||||
[diff deleteItemsWithIdentifiers:@[ @(feature.serial) ]];
|
||||
[_dataSource applySnapshot:diff animatingDifferences:NO];
|
||||
|
||||
[_places removeObjectForKey:@(feature.serial)];
|
||||
[self reloadStyle];
|
||||
}
|
||||
|
||||
- (void)reloadStyle {
|
||||
NSMutableDictionary<NSString *, UIColor *> *colorMapping = [NSMutableDictionary dictionary];
|
||||
for (GMSPlaceLookupController *config in _places.objectEnumerator) {
|
||||
NSString *placeID = config.placeID;
|
||||
if (placeID != nil) {
|
||||
colorMapping[placeID] = config.color;
|
||||
}
|
||||
}
|
||||
if ([_computedColorMapping isEqualToDictionary:colorMapping]) {
|
||||
// Skip restyling if the mapping hasn't actually changed, since restyling can be expensive.
|
||||
return;
|
||||
}
|
||||
_computedColorMapping = colorMapping;
|
||||
|
||||
[_mapView featureLayerOfFeatureType:GMSFeatureTypeAdministrativeAreaLevel2].style =
|
||||
^GMSFeatureStyle *(GMSPlaceFeature *feature) {
|
||||
UIColor *color = colorMapping[feature.placeID];
|
||||
if (!color) {
|
||||
return nil;
|
||||
}
|
||||
return [GMSFeatureStyle styleWithFillColor:[color colorWithAlphaComponent:0.5]
|
||||
strokeColor:color
|
||||
strokeWidth:1.5];
|
||||
};
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DoubleMapViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DoubleMapViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface DoubleMapViewController : UIViewController
|
||||
|
||||
@end
|
||||
77
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DoubleMapViewController.m
generated
Executable file
77
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/DoubleMapViewController.m
generated
Executable file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/DoubleMapViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface DoubleMapViewController () <GMSMapViewDelegate>
|
||||
@end
|
||||
|
||||
@implementation DoubleMapViewController {
|
||||
GMSMapView *_mapView;
|
||||
GMSMapView *_boundMapView;
|
||||
}
|
||||
|
||||
+ (GMSCameraPosition *)defaultCamera {
|
||||
return [GMSCameraPosition cameraWithLatitude:37.7847 longitude:-122.41 zoom:5];
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
// Two map views, second one has its camera target controlled by the first.
|
||||
CGRect frame = self.view.bounds;
|
||||
frame.size.height = frame.size.height / 2;
|
||||
_mapView = [GMSMapView mapWithFrame:frame camera:[DoubleMapViewController defaultCamera]];
|
||||
_mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight |
|
||||
UIViewAutoresizingFlexibleBottomMargin;
|
||||
|
||||
_mapView.delegate = self;
|
||||
[self.view addSubview:_mapView];
|
||||
|
||||
frame = self.view.bounds;
|
||||
frame.size.height = frame.size.height / 2;
|
||||
frame.origin.y = frame.size.height;
|
||||
_boundMapView = [GMSMapView mapWithFrame:frame camera:[DoubleMapViewController defaultCamera]];
|
||||
_boundMapView.autoresizingMask = UIViewAutoresizingFlexibleWidth |
|
||||
UIViewAutoresizingFlexibleHeight |
|
||||
UIViewAutoresizingFlexibleTopMargin;
|
||||
_boundMapView.settings.scrollGestures = NO;
|
||||
|
||||
[self.view addSubview:_boundMapView];
|
||||
}
|
||||
|
||||
- (void)viewWillTransitionToSize:(CGSize)size
|
||||
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
||||
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||
CGRect frame = self.view.bounds;
|
||||
frame.size.height = frame.size.height / 2;
|
||||
_mapView.frame = frame;
|
||||
}
|
||||
|
||||
- (void)mapView:(GMSMapView *)mapView didChangeCameraPosition:(GMSCameraPosition *)position {
|
||||
GMSCameraPosition *previousCamera = _boundMapView.camera;
|
||||
_boundMapView.camera = [GMSCameraPosition cameraWithTarget:position.target
|
||||
zoom:previousCamera.zoom
|
||||
bearing:previousCamera.bearing
|
||||
viewingAngle:previousCamera.viewingAngle];
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/FitBoundsViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/FitBoundsViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface FitBoundsViewController : UIViewController
|
||||
|
||||
@end
|
||||
95
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/FitBoundsViewController.m
generated
Executable file
95
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/FitBoundsViewController.m
generated
Executable file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/FitBoundsViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface FitBoundsViewController () <GMSMapViewDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation FitBoundsViewController {
|
||||
GMSMapView *_mapView;
|
||||
NSMutableArray<GMSMarker *> *_markers;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-37.81969
|
||||
longitude:144.966085
|
||||
zoom:4];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
_mapView.delegate = self;
|
||||
self.view = _mapView;
|
||||
|
||||
// Add a default marker around Sydney.
|
||||
GMSMarker *sydneyMarker = [[GMSMarker alloc] init];
|
||||
sydneyMarker.title = @"Sydney!";
|
||||
sydneyMarker.icon = [UIImage imageNamed:@"glow-marker"];
|
||||
sydneyMarker.position = CLLocationCoordinate2DMake(-33.8683, 151.2086);
|
||||
sydneyMarker.map = _mapView;
|
||||
|
||||
GMSMarker *anotherSydneyMarker = [[GMSMarker alloc] init];
|
||||
anotherSydneyMarker.title = @"Sydney 2!";
|
||||
anotherSydneyMarker.icon = [UIImage imageNamed:@"glow-marker"];
|
||||
anotherSydneyMarker.position = CLLocationCoordinate2DMake(-33.8683, 149.2086);
|
||||
anotherSydneyMarker.map = _mapView;
|
||||
|
||||
// Create a list of markers, adding the Sydney marker.
|
||||
_markers = [NSMutableArray<GMSMarker *> arrayWithObject:sydneyMarker];
|
||||
[_markers addObject:anotherSydneyMarker];
|
||||
|
||||
// Create a button that, when pressed, updates the camera to fit the bounds of the specified
|
||||
// markers.
|
||||
UIBarButtonItem *fitBoundsButton =
|
||||
[[UIBarButtonItem alloc] initWithTitle:@"Fit Bounds"
|
||||
style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(didTapFitBounds)];
|
||||
self.navigationItem.rightBarButtonItem = fitBoundsButton;
|
||||
}
|
||||
|
||||
- (void)didTapFitBounds {
|
||||
if (_markers.count == 0) return;
|
||||
CLLocationCoordinate2D firstPos = _markers.firstObject.position;
|
||||
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:firstPos
|
||||
coordinate:firstPos];
|
||||
for (GMSMarker *marker in _markers) {
|
||||
bounds = [bounds includingCoordinate:marker.position];
|
||||
}
|
||||
GMSCameraUpdate *update = [GMSCameraUpdate fitBounds:bounds withPadding:50.0f];
|
||||
[_mapView moveCamera:update];
|
||||
}
|
||||
|
||||
#pragma mark - GMSMapViewDelegate
|
||||
|
||||
- (void)mapView:(GMSMapView *)mapView didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate {
|
||||
GMSMarker *marker = [[GMSMarker alloc] init];
|
||||
marker.title = [NSString
|
||||
stringWithFormat:@"Marker at: %.2f,%.2f", coordinate.latitude, coordinate.longitude];
|
||||
marker.position = coordinate;
|
||||
marker.appearAnimation = kGMSMarkerAnimationPop;
|
||||
marker.map = _mapView;
|
||||
|
||||
// Add the new marker to the list of markers.
|
||||
[_markers addObject:marker];
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/FixedPanoramaViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/FixedPanoramaViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface FixedPanoramaViewController : UIViewController
|
||||
|
||||
@end
|
||||
45
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/FixedPanoramaViewController.m
generated
Executable file
45
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/FixedPanoramaViewController.m
generated
Executable file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/FixedPanoramaViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
static CLLocationCoordinate2D kPanoramaNear = {-33.732022, 150.312114};
|
||||
|
||||
@interface FixedPanoramaViewController () <GMSPanoramaViewDelegate>
|
||||
@end
|
||||
|
||||
@implementation FixedPanoramaViewController {
|
||||
GMSPanoramaView *_view;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
_view = [GMSPanoramaView panoramaWithFrame:CGRectZero nearCoordinate:kPanoramaNear];
|
||||
_view.camera = [GMSPanoramaCamera cameraWithHeading:180 pitch:-10 zoom:0];
|
||||
_view.delegate = self;
|
||||
_view.orientationGestures = NO;
|
||||
_view.navigationGestures = NO;
|
||||
_view.navigationLinksHidden = YES;
|
||||
self.view = _view;
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/FrameRateViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/FrameRateViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface FrameRateViewController : UIViewController
|
||||
|
||||
@end
|
||||
93
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/FrameRateViewController.m
generated
Executable file
93
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/FrameRateViewController.m
generated
Executable file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/FrameRateViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface FrameRateViewController ()
|
||||
|
||||
@end
|
||||
|
||||
@implementation FrameRateViewController {
|
||||
GMSMapView *_mapView;
|
||||
UITextView *_statusTextView;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
|
||||
longitude:151.2086
|
||||
zoom:6];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
self.view = _mapView;
|
||||
|
||||
// Add a display for the current frame rate mode.
|
||||
_statusTextView = [[UITextView alloc] init];
|
||||
_statusTextView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 0);
|
||||
_statusTextView.text = @"";
|
||||
_statusTextView.textAlignment = NSTextAlignmentCenter;
|
||||
_statusTextView.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.8f];
|
||||
_statusTextView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
_statusTextView.editable = NO;
|
||||
[self.view addSubview:_statusTextView];
|
||||
[_statusTextView sizeToFit];
|
||||
|
||||
// Add a button toggling through modes.
|
||||
self.navigationItem.rightBarButtonItem =
|
||||
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay
|
||||
target:self
|
||||
action:@selector(didTapNext)];
|
||||
[self updateStatus];
|
||||
}
|
||||
|
||||
- (void)didTapNext {
|
||||
_mapView.preferredFrameRate = [self nextFrameRate];
|
||||
[self updateStatus];
|
||||
}
|
||||
|
||||
+ (NSString *)nameForFrameRate:(GMSFrameRate)frameRate {
|
||||
switch (frameRate) {
|
||||
case kGMSFrameRatePowerSave:
|
||||
return @"PowerSave";
|
||||
case kGMSFrameRateConservative:
|
||||
return @"Conservative";
|
||||
case kGMSFrameRateMaximum:
|
||||
return @"Maximum";
|
||||
}
|
||||
}
|
||||
|
||||
- (GMSFrameRate)nextFrameRate {
|
||||
switch (_mapView.preferredFrameRate) {
|
||||
case kGMSFrameRatePowerSave:
|
||||
return kGMSFrameRateConservative;
|
||||
case kGMSFrameRateConservative:
|
||||
return kGMSFrameRateMaximum;
|
||||
case kGMSFrameRateMaximum:
|
||||
return kGMSFrameRatePowerSave;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)updateStatus {
|
||||
_statusTextView.text =
|
||||
[NSString stringWithFormat:@"Preferred frame rate: %@",
|
||||
[[self class] nameForFrameRate:_mapView.preferredFrameRate]];
|
||||
}
|
||||
|
||||
@end
|
||||
26
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GeocoderViewController.h
generated
Executable file
26
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GeocoderViewController.h
generated
Executable file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface GeocoderViewController : UIViewController <GMSMapViewDelegate>
|
||||
|
||||
@end
|
||||
75
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GeocoderViewController.m
generated
Executable file
75
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GeocoderViewController.m
generated
Executable file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/GeocoderViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@implementation GeocoderViewController {
|
||||
GMSMapView *_mapView;
|
||||
GMSGeocoder *_geocoder;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
|
||||
longitude:151.2086
|
||||
zoom:12];
|
||||
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
_mapView.delegate = self;
|
||||
|
||||
_geocoder = [[GMSGeocoder alloc] init];
|
||||
|
||||
self.view = _mapView;
|
||||
}
|
||||
|
||||
- (void)mapView:(GMSMapView *)mapView didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate {
|
||||
// On a long press, reverse geocode this location.
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
GMSReverseGeocodeCallback handler = ^(GMSReverseGeocodeResponse *response, NSError *error) {
|
||||
[weakSelf handleResponse:response coordinate:coordinate error:error];
|
||||
};
|
||||
[_geocoder reverseGeocodeCoordinate:coordinate completionHandler:handler];
|
||||
}
|
||||
|
||||
- (void)handleResponse:(nullable GMSReverseGeocodeResponse *)response
|
||||
coordinate:(CLLocationCoordinate2D)coordinate
|
||||
error:(nullable NSError *)error {
|
||||
GMSAddress *address = response.firstResult;
|
||||
if (address) {
|
||||
NSLog(@"Geocoder result: %@", address);
|
||||
|
||||
GMSMarker *marker = [GMSMarker markerWithPosition:address.coordinate];
|
||||
NSArray<NSString *> *lines = [address lines];
|
||||
|
||||
marker.title = [lines firstObject];
|
||||
if (lines.count > 1) {
|
||||
marker.snippet = [lines objectAtIndex:1];
|
||||
}
|
||||
|
||||
marker.appearAnimation = kGMSMarkerAnimationPop;
|
||||
marker.map = _mapView;
|
||||
} else {
|
||||
NSLog(@"Could not reverse geocode point (%f,%f): %@", coordinate.latitude, coordinate.longitude,
|
||||
error);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GestureControlViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GestureControlViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface GestureControlViewController : UIViewController
|
||||
|
||||
@end
|
||||
74
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GestureControlViewController.m
generated
Executable file
74
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GestureControlViewController.m
generated
Executable file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/GestureControlViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@implementation GestureControlViewController {
|
||||
GMSMapView *_mapView;
|
||||
UISwitch *_zoomSwitch;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-25.5605
|
||||
longitude:133.605097
|
||||
zoom:3];
|
||||
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
_mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
_mapView.accessibilityIdentifier = @"gestureControlDemoMapView";
|
||||
|
||||
self.view = [[UIView alloc] initWithFrame:CGRectZero];
|
||||
[self.view addSubview:_mapView];
|
||||
|
||||
UIView *holder = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 59)];
|
||||
holder.autoresizingMask =
|
||||
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
|
||||
holder.backgroundColor = [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.8f];
|
||||
[self.view addSubview:holder];
|
||||
|
||||
// Zoom label.
|
||||
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(16, 16, 200, 29)];
|
||||
label.text = @"Zooming?";
|
||||
label.font = [UIFont boldSystemFontOfSize:18.0f];
|
||||
label.textAlignment = NSTextAlignmentLeft;
|
||||
label.backgroundColor = [UIColor clearColor];
|
||||
label.layer.shadowColor = [[UIColor whiteColor] CGColor];
|
||||
label.layer.shadowOffset = CGSizeMake(0.0f, 1.0f);
|
||||
label.layer.shadowOpacity = 1.0f;
|
||||
label.layer.shadowRadius = 0.0f;
|
||||
[holder addSubview:label];
|
||||
|
||||
// Control zooming.
|
||||
_zoomSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(-90, 16, 0, 0)];
|
||||
_zoomSwitch.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
|
||||
[_zoomSwitch addTarget:self
|
||||
action:@selector(didChangeZoomSwitch)
|
||||
forControlEvents:UIControlEventValueChanged];
|
||||
_zoomSwitch.on = YES;
|
||||
[holder addSubview:_zoomSwitch];
|
||||
}
|
||||
|
||||
- (void)didChangeZoomSwitch {
|
||||
_mapView.settings.zoomGestures = _zoomSwitch.isOn;
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GradientPolylinesViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GradientPolylinesViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface GradientPolylinesViewController : UIViewController
|
||||
|
||||
@end
|
||||
91
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GradientPolylinesViewController.m
generated
Executable file
91
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GradientPolylinesViewController.m
generated
Executable file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/GradientPolylinesViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@implementation GradientPolylinesViewController {
|
||||
GMSMapView *_mapView;
|
||||
GMSPolyline *_polyline;
|
||||
NSMutableArray *_trackData;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:44.1314
|
||||
longitude:9.6921
|
||||
zoom:14.059f
|
||||
bearing:328.f
|
||||
viewingAngle:40.f];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
self.view = _mapView;
|
||||
|
||||
[self parseTrackFile];
|
||||
[_polyline setSpans:[self gradientSpans]];
|
||||
}
|
||||
|
||||
- (NSArray *)gradientSpans {
|
||||
NSMutableArray *colorSpans = [NSMutableArray array];
|
||||
NSUInteger count = _trackData.count;
|
||||
UIColor *prevColor;
|
||||
for (NSUInteger i = 0; i < count; i++) {
|
||||
NSDictionary *dict = [_trackData objectAtIndex:i];
|
||||
double elevation = [[dict objectForKey:@"elevation"] doubleValue];
|
||||
|
||||
UIColor *toColor = [UIColor colorWithHue:(float)elevation / 700
|
||||
saturation:1.f
|
||||
brightness:.9f
|
||||
alpha:1.f];
|
||||
|
||||
if (prevColor == nil) {
|
||||
prevColor = toColor;
|
||||
}
|
||||
|
||||
GMSStrokeStyle *style = [GMSStrokeStyle gradientFromColor:prevColor toColor:toColor];
|
||||
[colorSpans addObject:[GMSStyleSpan spanWithStyle:style]];
|
||||
|
||||
prevColor = toColor;
|
||||
}
|
||||
return colorSpans;
|
||||
}
|
||||
|
||||
- (void)parseTrackFile {
|
||||
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"track" ofType:@"json"];
|
||||
NSData *data = [NSData dataWithContentsOfFile:filePath];
|
||||
NSArray *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
|
||||
_trackData = [[NSMutableArray alloc] init];
|
||||
GMSMutablePath *path = [GMSMutablePath path];
|
||||
|
||||
for (NSUInteger i = 0; i < json.count; i++) {
|
||||
NSDictionary *info = [json objectAtIndex:i];
|
||||
NSNumber *elevation = [info objectForKey:@"elevation"];
|
||||
CLLocationDegrees lat = [[info objectForKey:@"lat"] doubleValue];
|
||||
CLLocationDegrees lng = [[info objectForKey:@"lng"] doubleValue];
|
||||
CLLocation *loc = [[CLLocation alloc] initWithLatitude:lat longitude:lng];
|
||||
[_trackData addObject:@{@"loc" : loc, @"elevation" : elevation}];
|
||||
[path addLatitude:lat longitude:lng];
|
||||
}
|
||||
|
||||
_polyline = [GMSPolyline polylineWithPath:path];
|
||||
_polyline.strokeWidth = 6;
|
||||
_polyline.map = _mapView;
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GroundOverlayViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GroundOverlayViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface GroundOverlayViewController : UIViewController
|
||||
|
||||
@end
|
||||
64
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GroundOverlayViewController.m
generated
Executable file
64
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/GroundOverlayViewController.m
generated
Executable file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/GroundOverlayViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface GroundOverlayViewController () <GMSMapViewDelegate>
|
||||
@end
|
||||
|
||||
@implementation GroundOverlayViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
CLLocationCoordinate2D southWest = CLLocationCoordinate2DMake(40.712216, -74.22655);
|
||||
CLLocationCoordinate2D northEast = CLLocationCoordinate2DMake(40.773941, -74.12544);
|
||||
|
||||
// Choose the midpoint of the coordinate to focus the camera on.
|
||||
CLLocationCoordinate2D newark = GMSGeometryInterpolate(southWest, northEast, 0.5);
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithTarget:newark
|
||||
zoom:12
|
||||
bearing:0
|
||||
viewingAngle:45];
|
||||
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
mapView.delegate = self;
|
||||
|
||||
// Add the ground overlay, centered in Newark, NJ
|
||||
GMSGroundOverlay *groundOverlay = [[GMSGroundOverlay alloc] init];
|
||||
GMSCoordinateBounds *overlayBounds = [[GMSCoordinateBounds alloc] initWithCoordinate:southWest
|
||||
coordinate:northEast];
|
||||
|
||||
// Image from http://www.lib.utexas.edu/maps/historical/newark_nj_1922.jpg
|
||||
groundOverlay.icon = [UIImage imageNamed:@"newark_nj_1922.jpg"];
|
||||
groundOverlay.tappable = YES;
|
||||
groundOverlay.position = newark;
|
||||
groundOverlay.bounds = overlayBounds;
|
||||
groundOverlay.map = mapView;
|
||||
|
||||
self.view = mapView;
|
||||
}
|
||||
|
||||
- (void)mapView:(GMSMapView *)mapView didTapOverlay:(GMSOverlay *)overlay {
|
||||
float opacity = (((float)arc4random() / 0x100000000) * 0.5f + 0.5f);
|
||||
((GMSGroundOverlay *)overlay).opacity = opacity;
|
||||
}
|
||||
|
||||
@end
|
||||
27
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/IndoorMuseumNavigationViewController.h
generated
Executable file
27
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/IndoorMuseumNavigationViewController.h
generated
Executable file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface IndoorMuseumNavigationViewController
|
||||
: UIViewController <GMSMapViewDelegate, GMSIndoorDisplayDelegate>
|
||||
|
||||
@end
|
||||
127
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/IndoorMuseumNavigationViewController.m
generated
Executable file
127
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/IndoorMuseumNavigationViewController.m
generated
Executable file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/IndoorMuseumNavigationViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@implementation IndoorMuseumNavigationViewController {
|
||||
GMSMapView *_mapView;
|
||||
NSArray *_exhibits; // Array of JSON exhibit data.
|
||||
NSDictionary *_exhibit; // The currently selected exhibit. Will be nil initially.
|
||||
GMSMarker *_marker;
|
||||
NSDictionary *_levels; // The levels dictionary is updated when a new building is selected, and
|
||||
// contains mapping from localized level name to GMSIndoorLevel.
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:38.8879
|
||||
longitude:-77.0200
|
||||
zoom:17];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
_mapView.settings.myLocationButton = NO;
|
||||
_mapView.settings.indoorPicker = NO;
|
||||
_mapView.delegate = self;
|
||||
_mapView.indoorDisplay.delegate = self;
|
||||
|
||||
self.view = _mapView;
|
||||
|
||||
// Load the exhibits configuration from JSON
|
||||
NSString *jsonPath = [[NSBundle mainBundle] pathForResource:@"museum-exhibits" ofType:@"json"];
|
||||
NSData *data = [NSData dataWithContentsOfFile:jsonPath];
|
||||
_exhibits = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
|
||||
|
||||
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] init];
|
||||
[segmentedControl setTintColor:[UIColor colorWithRed:0.373f green:0.667f blue:0.882f alpha:1.0f]];
|
||||
|
||||
segmentedControl.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[segmentedControl addTarget:self
|
||||
action:@selector(exhibitSelected:)
|
||||
forControlEvents:UIControlEventValueChanged];
|
||||
[self.view addSubview:segmentedControl];
|
||||
|
||||
for (NSDictionary *exhibit in _exhibits) {
|
||||
[segmentedControl insertSegmentWithImage:[UIImage imageNamed:exhibit[@"key"]]
|
||||
atIndex:[_exhibits indexOfObject:exhibit]
|
||||
animated:NO];
|
||||
}
|
||||
|
||||
NSDictionary *views = NSDictionaryOfVariableBindings(segmentedControl);
|
||||
|
||||
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"[segmentedControl]-|"
|
||||
options:kNilOptions
|
||||
metrics:nil
|
||||
views:views]];
|
||||
[self.view
|
||||
addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[segmentedControl]-|"
|
||||
options:kNilOptions
|
||||
metrics:nil
|
||||
views:views]];
|
||||
}
|
||||
|
||||
- (void)moveMarker {
|
||||
CLLocationCoordinate2D loc =
|
||||
CLLocationCoordinate2DMake([_exhibit[@"lat"] doubleValue], [_exhibit[@"lng"] doubleValue]);
|
||||
if (_marker == nil) {
|
||||
_marker = [GMSMarker markerWithPosition:loc];
|
||||
_marker.map = _mapView;
|
||||
} else {
|
||||
_marker.position = loc;
|
||||
}
|
||||
_marker.title = _exhibit[@"name"];
|
||||
[_mapView animateToLocation:loc];
|
||||
[_mapView animateToZoom:19];
|
||||
}
|
||||
|
||||
- (void)exhibitSelected:(UISegmentedControl *)segmentedControl {
|
||||
_exhibit = _exhibits[[segmentedControl selectedSegmentIndex]];
|
||||
[self moveMarker];
|
||||
}
|
||||
|
||||
#pragma mark - GMSMapViewDelegate
|
||||
|
||||
- (void)mapView:(GMSMapView *)mapView idleAtCameraPosition:(GMSCameraPosition *)camera {
|
||||
if (_exhibit != nil) {
|
||||
CLLocationCoordinate2D loc =
|
||||
CLLocationCoordinate2DMake([_exhibit[@"lat"] doubleValue], [_exhibit[@"lng"] doubleValue]);
|
||||
if ([_mapView.projection containsCoordinate:loc] && _levels != nil) {
|
||||
[mapView.indoorDisplay setActiveLevel:_levels[_exhibit[@"level"]]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - GMSIndoorDisplayDelegate
|
||||
|
||||
- (void)didChangeActiveBuilding:(GMSIndoorBuilding *)building {
|
||||
if (building != nil) {
|
||||
NSMutableDictionary *levels = [NSMutableDictionary dictionary];
|
||||
|
||||
for (GMSIndoorLevel *level in building.levels) {
|
||||
[levels setObject:level forKey:level.shortName];
|
||||
}
|
||||
|
||||
_levels = [NSDictionary dictionaryWithDictionary:levels];
|
||||
} else {
|
||||
_levels = nil;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/IndoorViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/IndoorViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface IndoorViewController : UIViewController
|
||||
|
||||
@end
|
||||
97
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/IndoorViewController.m
generated
Executable file
97
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/IndoorViewController.m
generated
Executable file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/IndoorViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
static NSString *const kNormalType = @"Normal";
|
||||
static NSString *const kRetroType = @"Retro";
|
||||
static NSString *const kGrayscaleType = @"Grayscale";
|
||||
static NSString *const kNightType = @"Night";
|
||||
|
||||
@interface IndoorViewController () <UIActionSheetDelegate>
|
||||
@end
|
||||
|
||||
@implementation IndoorViewController {
|
||||
GMSMapView *_mapView;
|
||||
UIBarButtonItem *_barButtonItem;
|
||||
GMSMapStyle *_retroStyle;
|
||||
GMSMapStyle *_grayscaleStyle;
|
||||
GMSMapStyle *_nightStyle;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
NSURL *retroURL = [[NSBundle mainBundle] URLForResource:@"mapstyle-retro" withExtension:@"json"];
|
||||
_retroStyle = [GMSMapStyle styleWithContentsOfFileURL:retroURL error:NULL];
|
||||
|
||||
NSURL *grayscaleURL = [[NSBundle mainBundle] URLForResource:@"mapstyle-silver"
|
||||
withExtension:@"json"];
|
||||
_grayscaleStyle = [GMSMapStyle styleWithContentsOfFileURL:grayscaleURL error:NULL];
|
||||
|
||||
NSURL *nightURL = [[NSBundle mainBundle] URLForResource:@"mapstyle-night" withExtension:@"json"];
|
||||
_nightStyle = [GMSMapStyle styleWithContentsOfFileURL:nightURL error:NULL];
|
||||
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:37.78318
|
||||
longitude:-122.403874
|
||||
zoom:18];
|
||||
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
|
||||
UIBarButtonItem *styleButton = [[UIBarButtonItem alloc] initWithTitle:@"Style"
|
||||
style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(changeMapStyle:)];
|
||||
self.navigationItem.rightBarButtonItem = styleButton;
|
||||
|
||||
self.view = _mapView;
|
||||
}
|
||||
|
||||
- (UIAlertAction *_Nonnull)actionWithTitle:(nonnull NSString *)title
|
||||
style:(nullable GMSMapStyle *)style {
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
return [UIAlertAction actionWithTitle:title
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction *_Nonnull action) {
|
||||
__strong __typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf) {
|
||||
strongSelf->_mapView.mapStyle = style;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)changeMapStyle:(UIBarButtonItem *)sender {
|
||||
UIAlertController *alert =
|
||||
[UIAlertController alertControllerWithTitle:@"Select map style"
|
||||
message:nil
|
||||
preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
[alert addAction:[self actionWithTitle:kRetroType style:_retroStyle]];
|
||||
[alert addAction:[self actionWithTitle:kGrayscaleType style:_grayscaleStyle]];
|
||||
[alert addAction:[self actionWithTitle:kNightType style:_nightStyle]];
|
||||
[alert addAction:[self actionWithTitle:kNormalType style:nil]];
|
||||
[alert addAction:[UIAlertAction actionWithTitle:@"Cancel"
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:nil]];
|
||||
alert.popoverPresentationController.barButtonItem = sender;
|
||||
[self presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MapLayerViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MapLayerViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface MapLayerViewController : UIViewController
|
||||
|
||||
@end
|
||||
90
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MapLayerViewController.m
generated
Executable file
90
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MapLayerViewController.m
generated
Executable file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MapLayerViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@implementation MapLayerViewController {
|
||||
GMSMapView *_mapView;
|
||||
BOOL _rotating;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-37.81969
|
||||
longitude:144.966085
|
||||
zoom:4];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
self.view = _mapView;
|
||||
|
||||
GMSMapView *mapView = _mapView;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
mapView.myLocationEnabled = YES;
|
||||
});
|
||||
|
||||
UIBarButtonItem *myLocationButton =
|
||||
[[UIBarButtonItem alloc] initWithTitle:@"Fly to My Location"
|
||||
style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(didTapMyLocation)];
|
||||
self.navigationItem.rightBarButtonItem = myLocationButton;
|
||||
}
|
||||
|
||||
- (void)didTapMyLocation {
|
||||
CLLocation *location = _mapView.myLocation;
|
||||
if (!location || !CLLocationCoordinate2DIsValid(location.coordinate)) {
|
||||
return;
|
||||
}
|
||||
GMSCameraPosition *camera =
|
||||
[[GMSCameraPosition alloc] initWithTarget:location.coordinate
|
||||
zoom:_mapView.camera.zoom
|
||||
bearing:0.0
|
||||
viewingAngle:_mapView.camera.viewingAngle];
|
||||
CAMediaTimingFunction *curve =
|
||||
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
|
||||
// Animate to the marker
|
||||
[CATransaction begin];
|
||||
[CATransaction setAnimationDuration:2.0f]; // 2 second animation
|
||||
[CATransaction setAnimationTimingFunction:curve];
|
||||
[CATransaction setCompletionBlock:^{
|
||||
if (_rotating) { // Animation was interrupted by orientation change.
|
||||
[CATransaction
|
||||
setDisableActions:true]; // Disable animation to avoid interruption from rotation.
|
||||
[_mapView animateToCameraPosition:camera];
|
||||
}
|
||||
}];
|
||||
|
||||
[_mapView animateToCameraPosition:camera];
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
- (void)viewWillTransitionToSize:(CGSize)size
|
||||
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
||||
_rotating = true;
|
||||
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||
[coordinator
|
||||
animateAlongsideTransition:nil
|
||||
completion:^(
|
||||
id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
||||
_rotating = false;
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MapTypesViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MapTypesViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface MapTypesViewController : UIViewController
|
||||
|
||||
@end
|
||||
75
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MapTypesViewController.m
generated
Executable file
75
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MapTypesViewController.m
generated
Executable file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MapTypesViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
static NSString *const kNormalType = @"Normal";
|
||||
static NSString *const kSatelliteType = @"Satellite";
|
||||
static NSString *const kHybridType = @"Hybrid";
|
||||
static NSString *const kTerrainType = @"Terrain";
|
||||
|
||||
@implementation MapTypesViewController {
|
||||
UISegmentedControl *_switcher;
|
||||
GMSMapView *_mapView;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
|
||||
longitude:151.2086
|
||||
zoom:12];
|
||||
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
self.view = _mapView;
|
||||
|
||||
// The possible different types to show.
|
||||
NSArray *types = @[ kNormalType, kSatelliteType, kHybridType, kTerrainType ];
|
||||
|
||||
// Create a UISegmentedControl that is the navigationItem's titleView.
|
||||
_switcher = [[UISegmentedControl alloc] initWithItems:types];
|
||||
_switcher.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin |
|
||||
UIViewAutoresizingFlexibleWidth |
|
||||
UIViewAutoresizingFlexibleBottomMargin;
|
||||
_switcher.selectedSegmentIndex = 0;
|
||||
self.navigationItem.titleView = _switcher;
|
||||
|
||||
// Listen to touch events on the UISegmentedControl.
|
||||
[_switcher addTarget:self
|
||||
action:@selector(didChangeSwitcher)
|
||||
forControlEvents:UIControlEventValueChanged];
|
||||
}
|
||||
|
||||
- (void)didChangeSwitcher {
|
||||
// Switch to the type clicked on.
|
||||
NSString *title = [_switcher titleForSegmentAtIndex:_switcher.selectedSegmentIndex];
|
||||
if ([kNormalType isEqualToString:title]) {
|
||||
_mapView.mapType = kGMSTypeNormal;
|
||||
} else if ([kSatelliteType isEqualToString:title]) {
|
||||
_mapView.mapType = kGMSTypeSatellite;
|
||||
} else if ([kHybridType isEqualToString:title]) {
|
||||
_mapView.mapType = kGMSTypeHybrid;
|
||||
} else if ([kTerrainType isEqualToString:title]) {
|
||||
_mapView.mapType = kGMSTypeTerrain;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MapZoomViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MapZoomViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface MapZoomViewController : UIViewController
|
||||
|
||||
@end
|
||||
88
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MapZoomViewController.m
generated
Executable file
88
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MapZoomViewController.m
generated
Executable file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MapZoomViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@implementation MapZoomViewController {
|
||||
GMSMapView *_mapView;
|
||||
UITextView *_zoomRangeView;
|
||||
NSUInteger _nextMode;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
|
||||
longitude:151.2086
|
||||
zoom:6];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
_mapView.settings.scrollGestures = NO;
|
||||
self.view = _mapView;
|
||||
|
||||
// Add a display for the current zoom range restriction.
|
||||
_zoomRangeView = [[UITextView alloc] init];
|
||||
_zoomRangeView.frame = CGRectMake(0, 0, CGRectGetWidth(self.view.frame), 0);
|
||||
_zoomRangeView.text = @"";
|
||||
_zoomRangeView.textAlignment = NSTextAlignmentCenter;
|
||||
_zoomRangeView.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.8f];
|
||||
_zoomRangeView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
_zoomRangeView.editable = NO;
|
||||
[self.view addSubview:_zoomRangeView];
|
||||
[_zoomRangeView sizeToFit];
|
||||
[self didTapNext];
|
||||
|
||||
// Add a button toggling through modes.
|
||||
self.navigationItem.rightBarButtonItem =
|
||||
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay
|
||||
target:self
|
||||
action:@selector(didTapNext)];
|
||||
}
|
||||
|
||||
- (void)didTapNext {
|
||||
NSString *label = @"";
|
||||
float minZoom = kGMSMinZoomLevel;
|
||||
float maxZoom = kGMSMaxZoomLevel;
|
||||
|
||||
switch (_nextMode) {
|
||||
case 0:
|
||||
label = @"Default";
|
||||
break;
|
||||
case 1:
|
||||
minZoom = 18;
|
||||
label = @"Zoomed in";
|
||||
break;
|
||||
case 2:
|
||||
maxZoom = 8;
|
||||
label = @"Zoomed out";
|
||||
break;
|
||||
case 3:
|
||||
minZoom = 10;
|
||||
maxZoom = 11.5;
|
||||
label = @"Small range";
|
||||
break;
|
||||
}
|
||||
_nextMode = (_nextMode + 1) % 4;
|
||||
|
||||
[_mapView setMinZoom:minZoom maxZoom:maxZoom];
|
||||
_zoomRangeView.text =
|
||||
[NSString stringWithFormat:@"%@ (%.2f - %.2f)", label, _mapView.minZoom, _mapView.maxZoom];
|
||||
}
|
||||
|
||||
@end
|
||||
26
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkerEventsViewController.h
generated
Executable file
26
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkerEventsViewController.h
generated
Executable file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface MarkerEventsViewController : UIViewController <GMSMapViewDelegate>
|
||||
|
||||
@end
|
||||
102
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkerEventsViewController.m
generated
Executable file
102
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkerEventsViewController.m
generated
Executable file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MarkerEventsViewController.h"
|
||||
|
||||
#import <QuartzCore/QuartzCore.h>
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@implementation MarkerEventsViewController {
|
||||
GMSMapView *_mapView;
|
||||
GMSMarker *_melbourneMarker;
|
||||
BOOL _rotating;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-37.81969
|
||||
longitude:144.966085
|
||||
zoom:4];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
|
||||
GMSMarker *sydneyMarker = [[GMSMarker alloc] init];
|
||||
sydneyMarker.position = CLLocationCoordinate2DMake(-33.8683, 151.2086);
|
||||
sydneyMarker.map = _mapView;
|
||||
|
||||
_melbourneMarker = [[GMSMarker alloc] init];
|
||||
_melbourneMarker.position = CLLocationCoordinate2DMake(-37.81969, 144.966085);
|
||||
_melbourneMarker.map = _mapView;
|
||||
|
||||
_mapView.delegate = self;
|
||||
self.view = _mapView;
|
||||
}
|
||||
|
||||
#pragma mark - GMSMapViewDelegate
|
||||
|
||||
- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker {
|
||||
if (marker == _melbourneMarker) {
|
||||
return [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Icon"]];
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {
|
||||
GMSCameraPosition *camera = [[GMSCameraPosition alloc] initWithTarget:marker.position
|
||||
zoom:8
|
||||
bearing:50
|
||||
viewingAngle:60];
|
||||
// Animate to the marker
|
||||
[CATransaction begin];
|
||||
[CATransaction setAnimationDuration:3.f]; // 3 second animation
|
||||
[CATransaction setCompletionBlock:^{
|
||||
if (_rotating) { // Animation was interrupted by orientation change.
|
||||
[CATransaction
|
||||
setDisableActions:true]; // Disable animation to avoid interruption from rotation.
|
||||
[_mapView animateToCameraPosition:camera];
|
||||
}
|
||||
}];
|
||||
|
||||
[mapView animateToCameraPosition:camera];
|
||||
[CATransaction commit];
|
||||
|
||||
// Melbourne marker has a InfoWindow so return NO to allow markerInfoWindow to fire. Also check
|
||||
// that the marker isn't already selected so that the InfoWindow doesn't close.
|
||||
if (marker == _melbourneMarker && mapView.selectedMarker != _melbourneMarker) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// The Tap has been handled so return YES
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)viewWillTransitionToSize:(CGSize)size
|
||||
withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
|
||||
_rotating = true;
|
||||
[coordinator
|
||||
animateAlongsideTransition:nil
|
||||
completion:^(
|
||||
id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
||||
_rotating = false;
|
||||
}];
|
||||
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkerInfoWindowViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkerInfoWindowViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface MarkerInfoWindowViewController : UIViewController
|
||||
|
||||
@end
|
||||
100
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkerInfoWindowViewController.m
generated
Executable file
100
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkerInfoWindowViewController.m
generated
Executable file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MarkerInfoWindowViewController.h"
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Common/UIViewController+GMSModals.h"
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface MarkerInfoWindowViewController () <GMSMapViewDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation MarkerInfoWindowViewController {
|
||||
GMSMarker *_sydneyMarker;
|
||||
GMSMarker *_melbourneMarker;
|
||||
GMSMarker *_brisbaneMarker;
|
||||
UIView *_contentView;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-37.81969
|
||||
longitude:144.966085
|
||||
zoom:4];
|
||||
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
|
||||
_sydneyMarker = [[GMSMarker alloc] init];
|
||||
_sydneyMarker.title = @"Sydney";
|
||||
_sydneyMarker.snippet = @"Population: 4,605,992";
|
||||
_sydneyMarker.position = CLLocationCoordinate2DMake(-33.8683, 151.2086);
|
||||
_sydneyMarker.map = mapView;
|
||||
NSLog(@"sydneyMarker: %@", _sydneyMarker);
|
||||
|
||||
_melbourneMarker.map = nil;
|
||||
_melbourneMarker = [[GMSMarker alloc] init];
|
||||
_melbourneMarker.title = @"Melbourne";
|
||||
_melbourneMarker.snippet = @"Population: 4,169,103";
|
||||
_melbourneMarker.position = CLLocationCoordinate2DMake(-37.81969, 144.966085);
|
||||
_melbourneMarker.map = mapView;
|
||||
NSLog(@"melbourneMarker: %@", _melbourneMarker);
|
||||
|
||||
_brisbaneMarker.map = nil;
|
||||
_brisbaneMarker = [[GMSMarker alloc] init];
|
||||
_brisbaneMarker.title = @"Brisbane";
|
||||
_brisbaneMarker.snippet = @"Population: 2,189,878";
|
||||
_brisbaneMarker.position = CLLocationCoordinate2DMake(-27.4710107, 153.0234489);
|
||||
_brisbaneMarker.map = mapView;
|
||||
NSLog(@"brisbaneMarker: %@", _brisbaneMarker);
|
||||
|
||||
_contentView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"aeroplane"]];
|
||||
|
||||
mapView.delegate = self;
|
||||
self.view = mapView;
|
||||
}
|
||||
|
||||
#pragma mark GMSMapViewDelegate
|
||||
|
||||
- (UIView *)mapView:(GMSMapView *)mapView markerInfoWindow:(GMSMarker *)marker {
|
||||
if (marker == _sydneyMarker) {
|
||||
return _contentView;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (UIView *)mapView:(GMSMapView *)mapView markerInfoContents:(GMSMarker *)marker {
|
||||
if (marker == _brisbaneMarker) {
|
||||
return _contentView;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)mapView:(GMSMapView *)mapView didCloseInfoWindowOfMarker:(GMSMarker *)marker {
|
||||
NSString *message =
|
||||
[NSString stringWithFormat:@"Info window for marker %@ closed.", marker.title];
|
||||
[self gms_showToastWithMessage:message];
|
||||
}
|
||||
|
||||
- (void)mapView:(GMSMapView *)mapView didLongPressInfoWindowOfMarker:(GMSMarker *)marker {
|
||||
NSString *message =
|
||||
[NSString stringWithFormat:@"Info window for marker %@ long pressed.", marker.title];
|
||||
[self gms_showToastWithMessage:message];
|
||||
}
|
||||
|
||||
@end
|
||||
26
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkerLayerViewController.h
generated
Executable file
26
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkerLayerViewController.h
generated
Executable file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface MarkerLayerViewController : UIViewController <GMSMapViewDelegate>
|
||||
|
||||
@end
|
||||
152
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkerLayerViewController.m
generated
Executable file
152
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkerLayerViewController.m
generated
Executable file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MarkerLayerViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface CoordsList : NSObject
|
||||
|
||||
@property(nonatomic, readonly, copy) GMSPath *path;
|
||||
@property(nonatomic, readonly) NSUInteger target;
|
||||
|
||||
- (id)initWithPath:(GMSPath *)path;
|
||||
|
||||
- (CLLocationCoordinate2D)next;
|
||||
|
||||
@end
|
||||
|
||||
@implementation CoordsList
|
||||
|
||||
- (id)initWithPath:(GMSPath *)path {
|
||||
if ((self = [super init])) {
|
||||
_path = [path copy];
|
||||
_target = 0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CLLocationCoordinate2D)next {
|
||||
++_target;
|
||||
if (_target == _path.count) {
|
||||
_target = 0;
|
||||
}
|
||||
return [_path coordinateAtIndex:_target];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation MarkerLayerViewController {
|
||||
GMSMapView *_mapView;
|
||||
GMSMarker *_fadedMarker;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
_mapView = [[GMSMapView alloc] init];
|
||||
_mapView.camera = [GMSCameraPosition cameraWithLatitude:50.6042 longitude:3.9599 zoom:5];
|
||||
_mapView.delegate = self;
|
||||
self.view = _mapView;
|
||||
|
||||
GMSMutablePath *coords;
|
||||
GMSMarker *marker;
|
||||
|
||||
// Create a plane that flies to several airports around western Europe.
|
||||
coords = [GMSMutablePath path];
|
||||
[coords addLatitude:52.310683 longitude:4.765121];
|
||||
[coords addLatitude:51.471386 longitude:-0.457148];
|
||||
[coords addLatitude:49.01378 longitude:2.5542943];
|
||||
[coords addLatitude:50.036194 longitude:8.554519];
|
||||
marker = [GMSMarker markerWithPosition:[coords coordinateAtIndex:0]];
|
||||
marker.icon = [UIImage imageNamed:@"aeroplane"];
|
||||
marker.groundAnchor = CGPointMake(0.5f, 0.5f);
|
||||
marker.flat = YES;
|
||||
marker.map = _mapView;
|
||||
marker.userData = [[CoordsList alloc] initWithPath:coords];
|
||||
[self animateToNextCoord:marker];
|
||||
|
||||
// Create a boat that moves around the Baltic Sea.
|
||||
coords = [GMSMutablePath path];
|
||||
[coords addLatitude:57.598335 longitude:11.290512];
|
||||
[coords addLatitude:55.665193 longitude:10.741196];
|
||||
[coords addLatitude:55.065787 longitude:11.083488];
|
||||
[coords addLatitude:54.699234 longitude:10.863762];
|
||||
[coords addLatitude:54.482805 longitude:12.061272];
|
||||
[coords addLatitude:55.819802 longitude:16.148186]; // final point
|
||||
[coords addLatitude:54.927142 longitude:16.455803]; // final point
|
||||
[coords addLatitude:54.482805 longitude:12.061272]; // and back again
|
||||
[coords addLatitude:54.699234 longitude:10.863762];
|
||||
[coords addLatitude:55.065787 longitude:11.083488];
|
||||
[coords addLatitude:55.665193 longitude:10.741196];
|
||||
marker = [GMSMarker markerWithPosition:[coords coordinateAtIndex:0]];
|
||||
marker.icon = [UIImage imageNamed:@"boat"];
|
||||
marker.map = _mapView;
|
||||
marker.userData = [[CoordsList alloc] initWithPath:coords];
|
||||
[self animateToNextCoord:marker];
|
||||
}
|
||||
|
||||
- (void)animateToNextCoord:(GMSMarker *)marker {
|
||||
CoordsList *coords = marker.userData;
|
||||
CLLocationCoordinate2D coord = [coords next];
|
||||
CLLocationCoordinate2D previous = marker.position;
|
||||
|
||||
CLLocationDirection heading = GMSGeometryHeading(previous, coord);
|
||||
CLLocationDistance distance = GMSGeometryDistance(previous, coord);
|
||||
|
||||
// If this marker is flat, implicitly trigger a change in rotation, which will finish quickly.
|
||||
if (marker.flat) {
|
||||
marker.rotation = heading;
|
||||
}
|
||||
|
||||
// Use CATransaction to set a custom duration for this animation. By default, changes to the
|
||||
// position are already animated, but with a very short default duration. When the animation is
|
||||
// complete, trigger another animation step.
|
||||
[CATransaction begin];
|
||||
[CATransaction setAnimationDuration:(distance / (50 * 1000))]; // custom duration, 50km/sec
|
||||
|
||||
__weak MarkerLayerViewController *weakSelf = self;
|
||||
[CATransaction setCompletionBlock:^{
|
||||
[weakSelf animateToNextCoord:marker];
|
||||
}];
|
||||
|
||||
marker.position = coord;
|
||||
|
||||
[CATransaction commit];
|
||||
}
|
||||
|
||||
- (void)fadeMarker:(GMSMarker *)marker {
|
||||
_fadedMarker.opacity = 1.0f; // reset previous faded marker
|
||||
|
||||
// Fade this new marker.
|
||||
_fadedMarker = marker;
|
||||
_fadedMarker.opacity = 0.5f;
|
||||
}
|
||||
|
||||
#pragma mark - GMSMapViewDelegate
|
||||
|
||||
- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker {
|
||||
[self fadeMarker:marker];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate {
|
||||
[self fadeMarker:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkersViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkersViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface MarkersViewController : UIViewController
|
||||
|
||||
@end
|
||||
92
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkersViewController.m
generated
Executable file
92
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MarkersViewController.m
generated
Executable file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MarkersViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@implementation MarkersViewController {
|
||||
GMSMarker *_sydneyMarker;
|
||||
GMSMarker *_melbourneMarker;
|
||||
GMSMarker *_fadeInMarker;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-37.81969
|
||||
longitude:144.966085
|
||||
zoom:4];
|
||||
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
|
||||
_sydneyMarker = [[GMSMarker alloc] init];
|
||||
_sydneyMarker.title = @"Sydney";
|
||||
_sydneyMarker.snippet = @"Population: 4,605,992";
|
||||
_sydneyMarker.position = CLLocationCoordinate2DMake(-33.8683, 151.2086);
|
||||
_sydneyMarker.flat = NO;
|
||||
_sydneyMarker.rotation = 30.0;
|
||||
NSLog(@"sydneyMarker: %@", _sydneyMarker);
|
||||
|
||||
GMSMarker *australiaMarker = [[GMSMarker alloc] init];
|
||||
australiaMarker.title = @"Australia";
|
||||
australiaMarker.position = CLLocationCoordinate2DMake(-27.994401, 140.07019);
|
||||
australiaMarker.appearAnimation = kGMSMarkerAnimationPop;
|
||||
australiaMarker.flat = YES;
|
||||
australiaMarker.draggable = YES;
|
||||
australiaMarker.groundAnchor = CGPointMake(0.5, 0.5);
|
||||
australiaMarker.icon = [UIImage imageNamed:@"australia"];
|
||||
australiaMarker.map = mapView;
|
||||
|
||||
_fadeInMarker = [[GMSMarker alloc] init];
|
||||
_fadeInMarker.title = @"Australia";
|
||||
_fadeInMarker.position = CLLocationCoordinate2DMake(-29.9959, 145.0719);
|
||||
_fadeInMarker.appearAnimation = kGMSMarkerAnimationFadeIn;
|
||||
_fadeInMarker.icon = [UIImage imageNamed:@"australia"];
|
||||
|
||||
// Set the marker in Sydney to be selected
|
||||
mapView.selectedMarker = _sydneyMarker;
|
||||
|
||||
self.view = mapView;
|
||||
self.navigationItem.rightBarButtonItem =
|
||||
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
|
||||
target:self
|
||||
action:@selector(didTapAdd)];
|
||||
}
|
||||
|
||||
- (void)didTapAdd {
|
||||
if (_sydneyMarker.map == nil) {
|
||||
_sydneyMarker.map = (GMSMapView *)self.view;
|
||||
} else {
|
||||
_sydneyMarker.map = nil;
|
||||
}
|
||||
|
||||
_melbourneMarker.map = nil;
|
||||
_melbourneMarker = [[GMSMarker alloc] init];
|
||||
_melbourneMarker.title = @"Melbourne";
|
||||
_melbourneMarker.snippet = @"Population: 4,169,103";
|
||||
_melbourneMarker.position = CLLocationCoordinate2DMake(-37.81969, 144.966085);
|
||||
_melbourneMarker.map = (GMSMapView *)self.view;
|
||||
|
||||
if (_fadeInMarker.map) {
|
||||
_fadeInMarker.map = nil;
|
||||
} else {
|
||||
_fadeInMarker.map = (GMSMapView *)self.view;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
26
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MyLocationViewController.h
generated
Executable file
26
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MyLocationViewController.h
generated
Executable file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface MyLocationViewController : UIViewController <GMSMapViewDelegate>
|
||||
|
||||
@end
|
||||
88
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MyLocationViewController.m
generated
Executable file
88
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/MyLocationViewController.m
generated
Executable file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MyLocationViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@implementation MyLocationViewController {
|
||||
GMSMapView *_mapView;
|
||||
BOOL _firstLocationUpdate;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
|
||||
longitude:151.2086
|
||||
zoom:12];
|
||||
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
_mapView.delegate = self;
|
||||
_mapView.settings.compassButton = YES;
|
||||
_mapView.settings.myLocationButton = YES;
|
||||
|
||||
// Listen to the myLocation property of GMSMapView.
|
||||
[_mapView addObserver:self
|
||||
forKeyPath:@"myLocation"
|
||||
options:NSKeyValueObservingOptionNew
|
||||
context:NULL];
|
||||
|
||||
self.view = _mapView;
|
||||
|
||||
// Ask for My Location data after the map has already been added to the UI.
|
||||
GMSMapView *mapView = _mapView;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
mapView.myLocationEnabled = YES;
|
||||
});
|
||||
}
|
||||
|
||||
- (void)mapView:(GMSMapView *)mapView didTapMyLocation:(CLLocationCoordinate2D)location {
|
||||
NSString *message = [NSString stringWithFormat:@"My Location Dot Tapped at: [lat: %f, lng: %f]",
|
||||
location.latitude, location.longitude];
|
||||
UIAlertController *alertController =
|
||||
[UIAlertController alertControllerWithTitle:@"Location Tapped"
|
||||
message:message
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK"
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction *action){
|
||||
}];
|
||||
[alertController addAction:okAction];
|
||||
[self presentViewController:alertController animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[_mapView removeObserver:self forKeyPath:@"myLocation" context:NULL];
|
||||
}
|
||||
|
||||
#pragma mark - KVO updates
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString *)keyPath
|
||||
ofObject:(id)object
|
||||
change:(NSDictionary *)change
|
||||
context:(void *)context {
|
||||
if (!_firstLocationUpdate) {
|
||||
// If the first location update has not yet been received, then jump to that location.
|
||||
_firstLocationUpdate = YES;
|
||||
CLLocation *location = [change objectForKey:NSKeyValueChangeNewKey];
|
||||
_mapView.camera = [GMSCameraPosition cameraWithTarget:location.coordinate zoom:14];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PaddingBehaviorViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PaddingBehaviorViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2017 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface PaddingBehaviorViewController : UIViewController
|
||||
|
||||
@end
|
||||
147
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PaddingBehaviorViewController.m
generated
Executable file
147
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PaddingBehaviorViewController.m
generated
Executable file
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright 2017 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/PaddingBehaviorViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
static CLLocationCoordinate2D kPanoramaNear = {40.761388, -73.978133};
|
||||
|
||||
@interface PaddingBehaviorViewController () <GMSMapViewDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation PaddingBehaviorViewController {
|
||||
GMSMapView *_mapView;
|
||||
GMSPanoramaView *_panoramaView;
|
||||
|
||||
UILabel *_statusLabel;
|
||||
UIButton *_changeBehaviorButton;
|
||||
UIButton *_toggleFrameButton;
|
||||
UIBarButtonItem *_toggleViewButton;
|
||||
|
||||
BOOL _hasShrunk;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
|
||||
longitude:151.2086
|
||||
zoom:6];
|
||||
_mapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
|
||||
_mapView.padding = UIEdgeInsetsMake(0, 20, 40, 60);
|
||||
_mapView.delegate = self;
|
||||
_mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
[self.view addSubview:_mapView];
|
||||
|
||||
// Add status label.
|
||||
_statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 0, 0, 30)];
|
||||
_statusLabel.textColor = [UIColor brownColor];
|
||||
_statusLabel.textAlignment = NSTextAlignmentLeft;
|
||||
_statusLabel.text = @"Behavior: Always";
|
||||
[_statusLabel sizeToFit];
|
||||
|
||||
// Add behavior modifier button.
|
||||
_changeBehaviorButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
_changeBehaviorButton.frame = CGRectMake(30, 30, 0, 0);
|
||||
[_changeBehaviorButton setTitle:@"Next Behavior" forState:UIControlStateNormal];
|
||||
[_changeBehaviorButton sizeToFit];
|
||||
[_changeBehaviorButton addTarget:self
|
||||
action:@selector(nextBehavior)
|
||||
forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
// Add frame animation button.
|
||||
_toggleViewButton = [[UIBarButtonItem alloc] initWithTitle:@"Toggle View"
|
||||
style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(toggleViewType)];
|
||||
self.navigationItem.rightBarButtonItem = _toggleViewButton;
|
||||
|
||||
// Add change view type button.
|
||||
_toggleFrameButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
||||
_toggleFrameButton.frame = CGRectMake(30, 60, 0, 0);
|
||||
[_toggleFrameButton setTitle:@"Animate Frame" forState:UIControlStateNormal];
|
||||
[_toggleFrameButton sizeToFit];
|
||||
[_toggleFrameButton addTarget:self
|
||||
action:@selector(toggleFrame)
|
||||
forControlEvents:UIControlEventTouchUpInside];
|
||||
|
||||
[_mapView addSubview:_statusLabel];
|
||||
[_mapView addSubview:_changeBehaviorButton];
|
||||
[_mapView addSubview:_toggleFrameButton];
|
||||
|
||||
_hasShrunk = NO;
|
||||
|
||||
// Pre-load PanoramaView
|
||||
_panoramaView = [GMSPanoramaView panoramaWithFrame:self.view.bounds nearCoordinate:kPanoramaNear];
|
||||
_panoramaView.autoresizingMask =
|
||||
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
}
|
||||
|
||||
#pragma mark - Button Click Handlers
|
||||
|
||||
- (void)toggleFrame {
|
||||
CGSize size = self.view.bounds.size;
|
||||
CGPoint point = self.view.bounds.origin;
|
||||
[UIView animateWithDuration:2.0
|
||||
animations:^{
|
||||
if (self->_hasShrunk) {
|
||||
self->_mapView.frame = self.view.bounds;
|
||||
self->_panoramaView.frame = self->_mapView.frame;
|
||||
} else {
|
||||
self->_mapView.frame =
|
||||
CGRectMake(point.x, point.y, size.width / 2, size.height / 2);
|
||||
self->_panoramaView.frame = self->_mapView.frame;
|
||||
}
|
||||
self->_hasShrunk = !self->_hasShrunk;
|
||||
[self.view setNeedsLayout];
|
||||
[self.view layoutIfNeeded];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)toggleViewType {
|
||||
if ([self.view.subviews containsObject:_mapView]) {
|
||||
[_mapView removeFromSuperview];
|
||||
[self.view addSubview:_panoramaView];
|
||||
[_panoramaView addSubview:_toggleFrameButton];
|
||||
} else {
|
||||
[_panoramaView removeFromSuperview];
|
||||
[self.view addSubview:_mapView];
|
||||
[_mapView addSubview:_toggleFrameButton];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)nextBehavior {
|
||||
switch (_mapView.paddingAdjustmentBehavior) {
|
||||
case kGMSMapViewPaddingAdjustmentBehaviorAlways:
|
||||
_mapView.paddingAdjustmentBehavior = kGMSMapViewPaddingAdjustmentBehaviorAutomatic;
|
||||
_statusLabel.text = @"Behavior: Automatic";
|
||||
break;
|
||||
case kGMSMapViewPaddingAdjustmentBehaviorAutomatic:
|
||||
_mapView.paddingAdjustmentBehavior = kGMSMapViewPaddingAdjustmentBehaviorNever;
|
||||
_statusLabel.text = @"Behavior: Never";
|
||||
break;
|
||||
case kGMSMapViewPaddingAdjustmentBehaviorNever:
|
||||
_mapView.paddingAdjustmentBehavior = kGMSMapViewPaddingAdjustmentBehaviorAlways;
|
||||
_statusLabel.text = @"Behavior: Always";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PanoramaViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PanoramaViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface PanoramaViewController : UIViewController
|
||||
|
||||
@end
|
||||
84
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PanoramaViewController.m
generated
Executable file
84
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PanoramaViewController.m
generated
Executable file
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/PanoramaViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
static CLLocationCoordinate2D kPanoramaNear = {40.761388, -73.978133};
|
||||
static CLLocationCoordinate2D kMarkerAt = {40.761455, -73.977814};
|
||||
|
||||
@interface PanoramaViewController () <GMSPanoramaViewDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation PanoramaViewController {
|
||||
GMSPanoramaView *_view;
|
||||
BOOL _configured;
|
||||
UILabel *_statusLabel;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
_view = [GMSPanoramaView panoramaWithFrame:CGRectZero nearCoordinate:kPanoramaNear];
|
||||
_view.backgroundColor = [UIColor grayColor];
|
||||
_view.delegate = self;
|
||||
self.view = _view;
|
||||
|
||||
// Add status label, initially hidden.
|
||||
_statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 30)];
|
||||
_statusLabel.alpha = 0.0f;
|
||||
_statusLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
_statusLabel.backgroundColor = [UIColor blueColor];
|
||||
_statusLabel.textColor = [UIColor whiteColor];
|
||||
_statusLabel.textAlignment = NSTextAlignmentCenter;
|
||||
|
||||
[_view addSubview:_statusLabel];
|
||||
}
|
||||
|
||||
#pragma mark - GMSPanoramaDelegate
|
||||
|
||||
- (void)panoramaView:(GMSPanoramaView *)panoramaView didMoveCamera:(GMSPanoramaCamera *)camera {
|
||||
NSLog(@"Camera: (%f,%f,%f)", camera.orientation.heading, camera.orientation.pitch, camera.zoom);
|
||||
}
|
||||
|
||||
- (void)panoramaView:(GMSPanoramaView *)view didMoveToPanorama:(GMSPanorama *)panorama {
|
||||
if (!_configured) {
|
||||
GMSMarker *marker = [GMSMarker markerWithPosition:kMarkerAt];
|
||||
marker.icon = [GMSMarker markerImageWithColor:[UIColor purpleColor]];
|
||||
marker.panoramaView = _view;
|
||||
|
||||
CLLocationDegrees heading = GMSGeometryHeading(kPanoramaNear, kMarkerAt);
|
||||
_view.camera = [GMSPanoramaCamera cameraWithHeading:heading pitch:0 zoom:1];
|
||||
|
||||
_configured = YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)panoramaViewDidStartRendering:(GMSPanoramaView *)panoramaView {
|
||||
_statusLabel.alpha = 0.8f;
|
||||
_statusLabel.text = @"Rendering";
|
||||
}
|
||||
|
||||
- (void)panoramaViewDidFinishRendering:(GMSPanoramaView *)panoramaView {
|
||||
_statusLabel.alpha = 0.0f;
|
||||
}
|
||||
|
||||
@end
|
||||
26
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PolygonsViewController.h
generated
Executable file
26
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PolygonsViewController.h
generated
Executable file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface PolygonsViewController : UIViewController <GMSMapViewDelegate>
|
||||
|
||||
@end
|
||||
285
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PolygonsViewController.m
generated
Executable file
285
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PolygonsViewController.m
generated
Executable file
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/PolygonsViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface PolygonsViewController ()
|
||||
|
||||
@property(nonatomic) GMSPolygon *polygonOfNewYork;
|
||||
@property(nonatomic) GMSPolygon *polygonOfNorthCarolina;
|
||||
|
||||
@end
|
||||
|
||||
@implementation PolygonsViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:39.13006
|
||||
longitude:-77.508545
|
||||
zoom:4];
|
||||
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
mapView.delegate = self; // needed for didTapOverlay delegate method
|
||||
|
||||
self.view = mapView;
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
[super viewDidAppear:animated];
|
||||
|
||||
// Create renderer related objects after view appears, so a renderer will be available; otherwise,
|
||||
// behavior is undefined (may result in null ptr derefs).
|
||||
GMSMapView *mapView = (GMSMapView *)self.view;
|
||||
|
||||
// Create the first polygon.
|
||||
GMSPolygon *polygon = [[GMSPolygon alloc] init];
|
||||
polygon.path = [self pathOfNewYorkState];
|
||||
polygon.holes = @[ [self pathOfNewYorkStateHole] ];
|
||||
polygon.title = @"New York";
|
||||
polygon.fillColor = [UIColor colorWithRed:0.25 green:0 blue:0 alpha:0.2f];
|
||||
polygon.strokeColor = [UIColor blackColor];
|
||||
polygon.strokeWidth = 2;
|
||||
polygon.tappable = YES;
|
||||
polygon.map = mapView;
|
||||
self.polygonOfNewYork = polygon;
|
||||
|
||||
// Copy the existing polygon and its settings and use it as a base for the second polygon.
|
||||
polygon = [polygon copy];
|
||||
polygon.title = @"North Carolina";
|
||||
polygon.path = [self pathOfNorthCarolina];
|
||||
polygon.fillColor = [UIColor colorWithRed:0 green:0.25 blue:0 alpha:0.5];
|
||||
polygon.map = mapView;
|
||||
self.polygonOfNorthCarolina = polygon;
|
||||
}
|
||||
|
||||
- (void)mapView:(GMSMapView *)mapView didTapOverlay:(GMSOverlay *)overlay {
|
||||
// When a polygon is tapped, randomly change its fill color to a new hue.
|
||||
if ([overlay isKindOfClass:[GMSPolygon class]]) {
|
||||
GMSPolygon *polygon = (GMSPolygon *)overlay;
|
||||
CGFloat hue = (((float)arc4random() / 0x100000000) * 1.0f);
|
||||
polygon.fillColor = [UIColor colorWithHue:hue saturation:1 brightness:1 alpha:0.5];
|
||||
}
|
||||
}
|
||||
|
||||
- (GMSPath *)pathOfNewYorkState {
|
||||
GMSMutablePath *path = [GMSMutablePath path];
|
||||
[path addLatitude:42.5142 longitude:-79.7624];
|
||||
[path addLatitude:42.7783 longitude:-79.0672];
|
||||
[path addLatitude:42.8508 longitude:-78.9313];
|
||||
[path addLatitude:42.9061 longitude:-78.9024];
|
||||
[path addLatitude:42.9554 longitude:-78.9313];
|
||||
[path addLatitude:42.9584 longitude:-78.9656];
|
||||
[path addLatitude:42.9886 longitude:-79.0219];
|
||||
[path addLatitude:43.0568 longitude:-79.0027];
|
||||
[path addLatitude:43.0769 longitude:-79.0727];
|
||||
[path addLatitude:43.1220 longitude:-79.0713];
|
||||
[path addLatitude:43.1441 longitude:-79.0302];
|
||||
[path addLatitude:43.1801 longitude:-79.0576];
|
||||
[path addLatitude:43.2482 longitude:-79.0604];
|
||||
[path addLatitude:43.2812 longitude:-79.0837];
|
||||
[path addLatitude:43.4509 longitude:-79.2004];
|
||||
[path addLatitude:43.6311 longitude:-78.6909];
|
||||
[path addLatitude:43.6321 longitude:-76.7958];
|
||||
[path addLatitude:43.9987 longitude:-76.4978];
|
||||
[path addLatitude:44.0965 longitude:-76.4388];
|
||||
[path addLatitude:44.1349 longitude:-76.3536];
|
||||
[path addLatitude:44.1989 longitude:-76.3124];
|
||||
[path addLatitude:44.2049 longitude:-76.2437];
|
||||
[path addLatitude:44.2413 longitude:-76.1655];
|
||||
[path addLatitude:44.2973 longitude:-76.1353];
|
||||
[path addLatitude:44.3327 longitude:-76.0474];
|
||||
[path addLatitude:44.3553 longitude:-75.9856];
|
||||
[path addLatitude:44.3749 longitude:-75.9196];
|
||||
[path addLatitude:44.3994 longitude:-75.8730];
|
||||
[path addLatitude:44.4308 longitude:-75.8221];
|
||||
[path addLatitude:44.4740 longitude:-75.8098];
|
||||
[path addLatitude:44.5425 longitude:-75.7288];
|
||||
[path addLatitude:44.6647 longitude:-75.5585];
|
||||
[path addLatitude:44.7672 longitude:-75.4088];
|
||||
[path addLatitude:44.8101 longitude:-75.3442];
|
||||
[path addLatitude:44.8383 longitude:-75.3058];
|
||||
[path addLatitude:44.8676 longitude:-75.2399];
|
||||
[path addLatitude:44.9211 longitude:-75.1204];
|
||||
[path addLatitude:44.9609 longitude:-74.9995];
|
||||
[path addLatitude:44.9803 longitude:-74.9899];
|
||||
[path addLatitude:44.9852 longitude:-74.9103];
|
||||
[path addLatitude:45.0017 longitude:-74.8856];
|
||||
[path addLatitude:45.0153 longitude:-74.8306];
|
||||
[path addLatitude:45.0046 longitude:-74.7633];
|
||||
[path addLatitude:45.0027 longitude:-74.7070];
|
||||
[path addLatitude:45.0007 longitude:-74.5642];
|
||||
[path addLatitude:44.9920 longitude:-74.1467];
|
||||
[path addLatitude:45.0037 longitude:-73.7306];
|
||||
[path addLatitude:45.0085 longitude:-73.4203];
|
||||
[path addLatitude:45.0109 longitude:-73.3430];
|
||||
[path addLatitude:44.9874 longitude:-73.3547];
|
||||
[path addLatitude:44.9648 longitude:-73.3379];
|
||||
[path addLatitude:44.9160 longitude:-73.3396];
|
||||
[path addLatitude:44.8354 longitude:-73.3739];
|
||||
[path addLatitude:44.8013 longitude:-73.3324];
|
||||
[path addLatitude:44.7419 longitude:-73.3667];
|
||||
[path addLatitude:44.6139 longitude:-73.3873];
|
||||
[path addLatitude:44.5787 longitude:-73.3736];
|
||||
[path addLatitude:44.4916 longitude:-73.3049];
|
||||
[path addLatitude:44.4289 longitude:-73.2953];
|
||||
[path addLatitude:44.3513 longitude:-73.3365];
|
||||
[path addLatitude:44.2757 longitude:-73.3118];
|
||||
[path addLatitude:44.1980 longitude:-73.3818];
|
||||
[path addLatitude:44.1142 longitude:-73.4079];
|
||||
[path addLatitude:44.0511 longitude:-73.4367];
|
||||
[path addLatitude:44.0165 longitude:-73.4065];
|
||||
[path addLatitude:43.9375 longitude:-73.4079];
|
||||
[path addLatitude:43.8771 longitude:-73.3749];
|
||||
[path addLatitude:43.8167 longitude:-73.3914];
|
||||
[path addLatitude:43.7790 longitude:-73.3557];
|
||||
[path addLatitude:43.6460 longitude:-73.4244];
|
||||
[path addLatitude:43.5893 longitude:-73.4340];
|
||||
[path addLatitude:43.5655 longitude:-73.3969];
|
||||
[path addLatitude:43.6112 longitude:-73.3818];
|
||||
[path addLatitude:43.6271 longitude:-73.3049];
|
||||
[path addLatitude:43.5764 longitude:-73.3063];
|
||||
[path addLatitude:43.5675 longitude:-73.2582];
|
||||
[path addLatitude:43.5227 longitude:-73.2445];
|
||||
[path addLatitude:43.2582 longitude:-73.2582];
|
||||
[path addLatitude:42.9715 longitude:-73.2733];
|
||||
[path addLatitude:42.8004 longitude:-73.2898];
|
||||
[path addLatitude:42.7460 longitude:-73.2664];
|
||||
[path addLatitude:42.4630 longitude:-73.3708];
|
||||
[path addLatitude:42.0840 longitude:-73.5095];
|
||||
[path addLatitude:42.0218 longitude:-73.4903];
|
||||
[path addLatitude:41.8808 longitude:-73.4999];
|
||||
[path addLatitude:41.2953 longitude:-73.5535];
|
||||
[path addLatitude:41.2128 longitude:-73.4834];
|
||||
[path addLatitude:41.1011 longitude:-73.7275];
|
||||
[path addLatitude:41.0237 longitude:-73.6644];
|
||||
[path addLatitude:40.9851 longitude:-73.6578];
|
||||
[path addLatitude:40.9509 longitude:-73.6132];
|
||||
[path addLatitude:41.1869 longitude:-72.4823];
|
||||
[path addLatitude:41.2551 longitude:-72.0950];
|
||||
[path addLatitude:41.3005 longitude:-71.9714];
|
||||
[path addLatitude:41.3108 longitude:-71.9193];
|
||||
[path addLatitude:41.1838 longitude:-71.7915];
|
||||
[path addLatitude:41.1249 longitude:-71.7929];
|
||||
[path addLatitude:41.0462 longitude:-71.7517];
|
||||
[path addLatitude:40.6306 longitude:-72.9465];
|
||||
[path addLatitude:40.5368 longitude:-73.4628];
|
||||
[path addLatitude:40.4887 longitude:-73.8885];
|
||||
[path addLatitude:40.5232 longitude:-73.9490];
|
||||
[path addLatitude:40.4772 longitude:-74.2271];
|
||||
[path addLatitude:40.4861 longitude:-74.2532];
|
||||
[path addLatitude:40.6468 longitude:-74.1866];
|
||||
[path addLatitude:40.6556 longitude:-74.0547];
|
||||
[path addLatitude:40.7618 longitude:-74.0156];
|
||||
[path addLatitude:40.8699 longitude:-73.9421];
|
||||
[path addLatitude:40.9980 longitude:-73.8934];
|
||||
[path addLatitude:41.0343 longitude:-73.9854];
|
||||
[path addLatitude:41.3268 longitude:-74.6274];
|
||||
[path addLatitude:41.3583 longitude:-74.7084];
|
||||
[path addLatitude:41.3811 longitude:-74.7101];
|
||||
[path addLatitude:41.4386 longitude:-74.8265];
|
||||
[path addLatitude:41.5075 longitude:-74.9913];
|
||||
[path addLatitude:41.6000 longitude:-75.0668];
|
||||
[path addLatitude:41.6719 longitude:-75.0366];
|
||||
[path addLatitude:41.7672 longitude:-75.0545];
|
||||
[path addLatitude:41.8808 longitude:-75.1945];
|
||||
[path addLatitude:42.0013 longitude:-75.3552];
|
||||
[path addLatitude:42.0003 longitude:-75.4266];
|
||||
[path addLatitude:42.0013 longitude:-77.0306];
|
||||
[path addLatitude:41.9993 longitude:-79.7250];
|
||||
[path addLatitude:42.0003 longitude:-79.7621];
|
||||
[path addLatitude:42.1827 longitude:-79.7621];
|
||||
[path addLatitude:42.5146 longitude:-79.7621];
|
||||
return path;
|
||||
}
|
||||
|
||||
- (GMSPath *)pathOfNewYorkStateHole {
|
||||
GMSMutablePath *path = [GMSMutablePath path];
|
||||
[path addLatitude:43.5000 longitude:-76.3651];
|
||||
[path addLatitude:43.5000 longitude:-74.3651];
|
||||
[path addLatitude:42.0000 longitude:-74.3651];
|
||||
return path;
|
||||
}
|
||||
|
||||
- (GMSPath *)pathOfNorthCarolina {
|
||||
GMSMutablePath *path = [GMSMutablePath path];
|
||||
[path addLatitude:33.7963 longitude:-78.4850];
|
||||
[path addLatitude:34.8037 longitude:-79.6742];
|
||||
[path addLatitude:34.8206 longitude:-80.8003];
|
||||
[path addLatitude:34.9377 longitude:-80.7880];
|
||||
[path addLatitude:35.1019 longitude:-80.9377];
|
||||
[path addLatitude:35.0356 longitude:-81.0379];
|
||||
[path addLatitude:35.1457 longitude:-81.0324];
|
||||
[path addLatitude:35.1660 longitude:-81.3867];
|
||||
[path addLatitude:35.1985 longitude:-82.2739];
|
||||
[path addLatitude:35.2041 longitude:-82.3933];
|
||||
[path addLatitude:35.0637 longitude:-82.7765];
|
||||
[path addLatitude:35.0817 longitude:-82.7861];
|
||||
[path addLatitude:34.9996 longitude:-83.1075];
|
||||
[path addLatitude:34.9918 longitude:-83.6183];
|
||||
[path addLatitude:34.9918 longitude:-84.3201];
|
||||
[path addLatitude:35.2131 longitude:-84.2885];
|
||||
[path addLatitude:35.2680 longitude:-84.2226];
|
||||
[path addLatitude:35.2310 longitude:-84.1113];
|
||||
[path addLatitude:35.2815 longitude:-84.0454];
|
||||
[path addLatitude:35.4058 longitude:-84.0248];
|
||||
[path addLatitude:35.4719 longitude:-83.9424];
|
||||
[path addLatitude:35.5166 longitude:-83.8559];
|
||||
[path addLatitude:35.5512 longitude:-83.6938];
|
||||
[path addLatitude:35.5680 longitude:-83.5181];
|
||||
[path addLatitude:35.6327 longitude:-83.3849];
|
||||
[path addLatitude:35.7142 longitude:-83.2475];
|
||||
[path addLatitude:35.7799 longitude:-82.9962];
|
||||
[path addLatitude:35.8445 longitude:-82.9276];
|
||||
[path addLatitude:35.9224 longitude:-82.8191];
|
||||
[path addLatitude:35.9958 longitude:-82.7710];
|
||||
[path addLatitude:36.0613 longitude:-82.6419];
|
||||
[path addLatitude:35.9702 longitude:-82.6103];
|
||||
[path addLatitude:35.9547 longitude:-82.5677];
|
||||
[path addLatitude:36.0236 longitude:-82.4730];
|
||||
[path addLatitude:36.0669 longitude:-82.4194];
|
||||
[path addLatitude:36.1168 longitude:-82.3535];
|
||||
[path addLatitude:36.1345 longitude:-82.2862];
|
||||
[path addLatitude:36.1467 longitude:-82.1461];
|
||||
[path addLatitude:36.1035 longitude:-82.1228];
|
||||
[path addLatitude:36.1268 longitude:-82.0267];
|
||||
[path addLatitude:36.2797 longitude:-81.9360];
|
||||
[path addLatitude:36.3527 longitude:-81.7987];
|
||||
[path addLatitude:36.3361 longitude:-81.7081];
|
||||
[path addLatitude:36.5880 longitude:-81.6724];
|
||||
[path addLatitude:36.5659 longitude:-80.7234];
|
||||
[path addLatitude:36.5438 longitude:-80.2977];
|
||||
[path addLatitude:36.5449 longitude:-79.6729];
|
||||
[path addLatitude:36.5449 longitude:-77.2559];
|
||||
[path addLatitude:36.5505 longitude:-75.7562];
|
||||
[path addLatitude:36.3129 longitude:-75.7068];
|
||||
[path addLatitude:35.7131 longitude:-75.4129];
|
||||
[path addLatitude:35.2041 longitude:-75.4720];
|
||||
[path addLatitude:34.9794 longitude:-76.0748];
|
||||
[path addLatitude:34.5258 longitude:-76.4951];
|
||||
[path addLatitude:34.5880 longitude:-76.8109];
|
||||
[path addLatitude:34.5314 longitude:-77.1378];
|
||||
[path addLatitude:34.3910 longitude:-77.4481];
|
||||
[path addLatitude:34.0481 longitude:-77.7983];
|
||||
[path addLatitude:33.7666 longitude:-77.9260];
|
||||
[path addLatitude:33.7963 longitude:-78.4863];
|
||||
return path;
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PolylinesViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PolylinesViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface PolylinesViewController : UIViewController
|
||||
|
||||
@end
|
||||
102
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PolylinesViewController.m
generated
Executable file
102
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/PolylinesViewController.m
generated
Executable file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/PolylinesViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
static CLLocationCoordinate2D kSydneyAustralia = {-33.866901, 151.195988};
|
||||
static CLLocationCoordinate2D kHawaiiUSA = {21.291982, -157.821856};
|
||||
static CLLocationCoordinate2D kFiji = {-18, 179};
|
||||
static CLLocationCoordinate2D kMountainViewUSA = {37.423802, -122.091859};
|
||||
static CLLocationCoordinate2D kLimaPeru = {-12, -77};
|
||||
static bool kAnimate = true;
|
||||
|
||||
@implementation PolylinesViewController {
|
||||
NSArray *_styles;
|
||||
NSArray *_lengths;
|
||||
NSArray *_polys;
|
||||
double _pos, _step;
|
||||
GMSMapView *_mapView;
|
||||
}
|
||||
|
||||
- (void)tick {
|
||||
for (GMSPolyline *poly in _polys) {
|
||||
poly.spans = GMSStyleSpansOffset(poly.path, _styles, _lengths, kGMSLengthGeodesic, _pos);
|
||||
}
|
||||
_pos -= _step;
|
||||
if (kAnimate) {
|
||||
__weak id weakSelf = self;
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC / 10), dispatch_get_main_queue(),
|
||||
^{
|
||||
[weakSelf tick];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)initLines {
|
||||
if (!_polys) {
|
||||
NSMutableArray *polys = [NSMutableArray array];
|
||||
GMSMutablePath *path = [GMSMutablePath path];
|
||||
[path addCoordinate:kSydneyAustralia];
|
||||
[path addCoordinate:kFiji];
|
||||
[path addCoordinate:kHawaiiUSA];
|
||||
[path addCoordinate:kMountainViewUSA];
|
||||
[path addCoordinate:kLimaPeru];
|
||||
[path addCoordinate:kSydneyAustralia];
|
||||
path = [path pathOffsetByLatitude:-30 longitude:0];
|
||||
_lengths = @[ @([path lengthOfKind:kGMSLengthGeodesic] / 21) ];
|
||||
for (int i = 0; i < 30; ++i) {
|
||||
GMSPolyline *poly = [[GMSPolyline alloc] init];
|
||||
poly.path = [path pathOffsetByLatitude:(i * 1.5) longitude:0];
|
||||
poly.strokeWidth = 8;
|
||||
poly.geodesic = YES;
|
||||
poly.map = _mapView;
|
||||
[polys addObject:poly];
|
||||
}
|
||||
_polys = polys;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-30 longitude:-175 zoom:3];
|
||||
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
mapView.accessibilityElementsHidden = YES;
|
||||
self.view = mapView;
|
||||
_mapView = mapView;
|
||||
|
||||
CGFloat alpha = 1;
|
||||
UIColor *green = [UIColor colorWithRed:0 green:1 blue:0 alpha:alpha];
|
||||
UIColor *greenTransp = [UIColor colorWithRed:0 green:1 blue:0 alpha:0];
|
||||
UIColor *red = [UIColor colorWithRed:1 green:0 blue:0 alpha:alpha];
|
||||
UIColor *redTransp = [UIColor colorWithRed:1 green:0 blue:0 alpha:0];
|
||||
GMSStrokeStyle *grad1 = [GMSStrokeStyle gradientFromColor:green toColor:greenTransp];
|
||||
GMSStrokeStyle *grad2 = [GMSStrokeStyle gradientFromColor:redTransp toColor:red];
|
||||
_styles = @[
|
||||
grad1,
|
||||
grad2,
|
||||
[GMSStrokeStyle solidColor:[UIColor colorWithWhite:0 alpha:0]],
|
||||
];
|
||||
_step = 50000;
|
||||
[self initLines];
|
||||
[self tick];
|
||||
}
|
||||
|
||||
@end
|
||||
37
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/Samples.h
generated
Executable file
37
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/Samples.h
generated
Executable file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/** Type defining the sample definition returned from +newDemo:withTitle:andDescription:. */
|
||||
typedef NSDictionary<NSString *, id> DemoDefinition;
|
||||
|
||||
/** This class defines the list of sample demos included in this app. */
|
||||
@interface Samples : NSObject
|
||||
|
||||
/** Returns a list of section names into which sample demos should be grouped. */
|
||||
+ (NSArray<NSString *> *)loadSections;
|
||||
|
||||
/** Returns one list of sample demos for each section. */
|
||||
+ (NSArray<NSArray<DemoDefinition *> *> *)loadDemos;
|
||||
|
||||
+ (DemoDefinition *)newDemo:(Class)viewControllerClass
|
||||
withTitle:(NSString *)title
|
||||
andDescription:(nullable NSString *)description;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
170
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/Samples.m
generated
Executable file
170
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/Samples.m
generated
Executable file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/Samples.h"
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/AnimatedCurrentLocationViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/AnimatedUIViewMarkerViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/BasicMapViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/CameraViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/CustomIndoorViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/CustomMarkersViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingBasicViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingEventsViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/DataDrivenStylingSearchViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/DoubleMapViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/FitBoundsViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/FixedPanoramaViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/FrameRateViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/GeocoderViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/GestureControlViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/GradientPolylinesViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/GroundOverlayViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/IndoorMuseumNavigationViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/IndoorViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MapLayerViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MapTypesViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MapZoomViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MarkerEventsViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MarkerInfoWindowViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MarkerLayerViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MarkersViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/MyLocationViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/PaddingBehaviorViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/PanoramaViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/PolygonsViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/PolylinesViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/SnapshotReadyViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/StampedPolylinesViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/StructuredGeocoderViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/StyledMapViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/TileLayerViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/TrafficMapViewController.h"
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/VisibleRegionViewController.h"
|
||||
|
||||
@implementation Samples
|
||||
|
||||
+ (NSArray<NSString *> *)loadSections {
|
||||
return @[ @"Map", @"Panorama", @"Overlays", @"Camera", @"Data-driven styling", @"Services" ];
|
||||
}
|
||||
|
||||
+ (NSArray<NSArray<DemoDefinition *> *> *)loadDemos {
|
||||
NSArray<DemoDefinition *> *mapDemos = @[
|
||||
[self newDemo:[BasicMapViewController class] withTitle:@"Basic Map" andDescription:nil],
|
||||
[self newDemo:[MapTypesViewController class] withTitle:@"Map Types" andDescription:nil],
|
||||
[self newDemo:[StampedPolylinesViewController class]
|
||||
withTitle:@"Stamped Polylines"
|
||||
andDescription:nil],
|
||||
[self newDemo:[TrafficMapViewController class] withTitle:@"Traffic Layer" andDescription:nil],
|
||||
[self newDemo:[MyLocationViewController class] withTitle:@"My Location" andDescription:nil],
|
||||
[self newDemo:[IndoorViewController class] withTitle:@"Indoor" andDescription:nil],
|
||||
[self newDemo:[CustomIndoorViewController class]
|
||||
withTitle:@"Indoor with Custom Level Select"
|
||||
andDescription:nil],
|
||||
[self newDemo:[IndoorMuseumNavigationViewController class]
|
||||
withTitle:@"Indoor Museum Navigator"
|
||||
andDescription:nil],
|
||||
[self newDemo:[GestureControlViewController class]
|
||||
withTitle:@"Gesture Control"
|
||||
andDescription:nil],
|
||||
[self newDemo:[SnapshotReadyViewController class]
|
||||
withTitle:@"Snapshot Ready"
|
||||
andDescription:nil],
|
||||
[self newDemo:[DoubleMapViewController class] withTitle:@"Two Maps" andDescription:nil],
|
||||
[self newDemo:[VisibleRegionViewController class]
|
||||
withTitle:@"Visible Regions"
|
||||
andDescription:nil],
|
||||
[self newDemo:[MapZoomViewController class] withTitle:@"Min/Max Zoom" andDescription:nil],
|
||||
[self newDemo:[FrameRateViewController class] withTitle:@"Frame Rate" andDescription:nil],
|
||||
[self newDemo:[PaddingBehaviorViewController class]
|
||||
withTitle:@"Padding Behavior"
|
||||
andDescription:nil],
|
||||
[self newDemo:[StyledMapViewController class] withTitle:@"Styled Map" andDescription:nil],
|
||||
];
|
||||
|
||||
NSArray<DemoDefinition *> *panoramaDemos = @[
|
||||
[self newDemo:[PanoramaViewController class] withTitle:@"Street View" andDescription:nil],
|
||||
[self newDemo:[FixedPanoramaViewController class]
|
||||
withTitle:@"Fixed Street View"
|
||||
andDescription:nil]
|
||||
];
|
||||
|
||||
NSArray<DemoDefinition *> *overlayDemos = @[
|
||||
[self newDemo:[MarkersViewController class] withTitle:@"Markers" andDescription:nil],
|
||||
[self newDemo:[CustomMarkersViewController class]
|
||||
withTitle:@"Custom Markers"
|
||||
andDescription:nil],
|
||||
[self newDemo:[AnimatedUIViewMarkerViewController class]
|
||||
withTitle:@"UIView Markers"
|
||||
andDescription:nil],
|
||||
[self newDemo:[MarkerEventsViewController class] withTitle:@"Marker Events" andDescription:nil],
|
||||
[self newDemo:[MarkerLayerViewController class] withTitle:@"Marker Layer" andDescription:nil],
|
||||
[self newDemo:[MarkerInfoWindowViewController class]
|
||||
withTitle:@"Custom Info Windows"
|
||||
andDescription:nil],
|
||||
[self newDemo:[PolygonsViewController class] withTitle:@"Polygons" andDescription:nil],
|
||||
[self newDemo:[PolylinesViewController class] withTitle:@"Polylines" andDescription:nil],
|
||||
[self newDemo:[GroundOverlayViewController class]
|
||||
withTitle:@"Ground Overlays"
|
||||
andDescription:nil],
|
||||
[self newDemo:[TileLayerViewController class] withTitle:@"Tile Layers" andDescription:nil],
|
||||
[self newDemo:[AnimatedCurrentLocationViewController class]
|
||||
withTitle:@"Animated Current Location"
|
||||
andDescription:nil],
|
||||
[self newDemo:[GradientPolylinesViewController class]
|
||||
withTitle:@"Gradient Polylines"
|
||||
andDescription:nil]
|
||||
];
|
||||
|
||||
NSArray<DemoDefinition *> *cameraDemos = @[
|
||||
[self newDemo:[FitBoundsViewController class] withTitle:@"Fit Bounds" andDescription:nil],
|
||||
[self newDemo:[CameraViewController class] withTitle:@"Camera Animation" andDescription:nil],
|
||||
[self newDemo:[MapLayerViewController class] withTitle:@"Map Layer" andDescription:nil]
|
||||
];
|
||||
|
||||
NSArray<DemoDefinition *> *dataDrivenStylingDemos = @[
|
||||
[self newDemo:[DataDrivenStylingBasicViewController class]
|
||||
withTitle:@"Basic"
|
||||
andDescription:nil],
|
||||
[self newDemo:[DataDrivenStylingEventsViewController class]
|
||||
withTitle:@"Events"
|
||||
andDescription:nil],
|
||||
[self newDemo:[DataDrivenStylingSearchViewController class]
|
||||
withTitle:@"Places from text search"
|
||||
andDescription:nil]
|
||||
];
|
||||
|
||||
NSArray<DemoDefinition *> *servicesDemos = @[
|
||||
[self newDemo:[GeocoderViewController class] withTitle:@"Geocoder" andDescription:nil],
|
||||
[self newDemo:[StructuredGeocoderViewController class]
|
||||
withTitle:@"Structured Geocoder"
|
||||
andDescription:nil],
|
||||
];
|
||||
|
||||
return @[
|
||||
mapDemos, panoramaDemos, overlayDemos, cameraDemos, dataDrivenStylingDemos, servicesDemos
|
||||
];
|
||||
}
|
||||
|
||||
+ (DemoDefinition *)newDemo:(Class)viewControllerClass
|
||||
withTitle:(NSString *)title
|
||||
andDescription:(NSString *)description {
|
||||
return [[DemoDefinition alloc]
|
||||
initWithObjectsAndKeys:viewControllerClass, @"controller", title, @"title",
|
||||
NSStringFromClass(viewControllerClass), @"className", description,
|
||||
@"description", nil];
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/SnapshotReadyViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/SnapshotReadyViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface SnapshotReadyViewController : UIViewController
|
||||
|
||||
@end
|
||||
114
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/SnapshotReadyViewController.m
generated
Executable file
114
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/SnapshotReadyViewController.m
generated
Executable file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/SnapshotReadyViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface SnapshotReadyViewController () <GMSMapViewDelegate>
|
||||
@end
|
||||
|
||||
@implementation SnapshotReadyViewController {
|
||||
GMSMapView *_mapView;
|
||||
UILabel *_statusLabel;
|
||||
UIBarButtonItem *_waitButton;
|
||||
BOOL _isAwaitingSnapshot;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
|
||||
longitude:151.2086
|
||||
zoom:6];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
_mapView.delegate = self;
|
||||
self.view = _mapView;
|
||||
|
||||
// Add status label, initially hidden.
|
||||
_statusLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 30)];
|
||||
_statusLabel.alpha = 0.0f;
|
||||
_statusLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
_statusLabel.backgroundColor = [UIColor blueColor];
|
||||
_statusLabel.textColor = [UIColor whiteColor];
|
||||
_statusLabel.textAlignment = NSTextAlignmentCenter;
|
||||
|
||||
// Add a wait button to signify on the next SnapshotReady event, a screenshot of the map will be
|
||||
// taken.
|
||||
_waitButton = [[UIBarButtonItem alloc] initWithTitle:@"Wait for snapshot"
|
||||
style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(didTapWait)];
|
||||
self.navigationItem.rightBarButtonItems = @[ _waitButton ];
|
||||
[_mapView addSubview:_statusLabel];
|
||||
}
|
||||
|
||||
#pragma mark GMSMapViewDelegate
|
||||
|
||||
- (void)mapViewSnapshotReady:(GMSMapView *)mapView {
|
||||
if (_isAwaitingSnapshot) {
|
||||
_isAwaitingSnapshot = NO;
|
||||
_waitButton.enabled = YES;
|
||||
_waitButton.title = @"Wait for snapshot";
|
||||
[self takeSnapshot];
|
||||
}
|
||||
|
||||
_statusLabel.alpha = 0.8f;
|
||||
_statusLabel.text = @"Snapshot Ready";
|
||||
|
||||
// Remove status label after 1 second.
|
||||
UILabel *statusLabel = _statusLabel;
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
||||
statusLabel.alpha = 0.0f;
|
||||
});
|
||||
}
|
||||
|
||||
#pragma mark Private
|
||||
|
||||
- (void)didTapWait {
|
||||
_isAwaitingSnapshot = YES;
|
||||
_waitButton.enabled = NO;
|
||||
_waitButton.title = @"Waiting";
|
||||
}
|
||||
|
||||
- (void)takeSnapshot {
|
||||
// Take a snapshot of the map.
|
||||
UIGraphicsBeginImageContextWithOptions(_mapView.bounds.size, YES, 0);
|
||||
[_mapView drawViewHierarchyInRect:_mapView.bounds afterScreenUpdates:YES];
|
||||
UIImage *mapSnapShot = UIGraphicsGetImageFromCurrentImageContext();
|
||||
UIGraphicsEndImageContext();
|
||||
|
||||
// Put snapshot image into an UIImageView and overlay on top of map.
|
||||
UIImageView *imageView = [[UIImageView alloc] initWithImage:mapSnapShot];
|
||||
imageView.layer.borderColor = [UIColor redColor].CGColor;
|
||||
imageView.layer.borderWidth = 10.0f;
|
||||
[_mapView addSubview:imageView];
|
||||
|
||||
// Remove imageView after 1 second.
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
|
||||
[UIView animateWithDuration:1
|
||||
animations:^{
|
||||
imageView.alpha = 0.0f;
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
[imageView removeFromSuperview];
|
||||
}];
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/StampedPolylinesViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/StampedPolylinesViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2020 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface StampedPolylinesViewController : UIViewController
|
||||
|
||||
@end
|
||||
126
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/StampedPolylinesViewController.m
generated
Executable file
126
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/StampedPolylinesViewController.m
generated
Executable file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright 2020 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/StampedPolylinesViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
static const double kSeattleLatitudeDegrees = 47.6089945;
|
||||
static const double kSeattleLongitudeDegrees = -122.3410462;
|
||||
static const double kZoom = 14;
|
||||
static const double kStrokeWidth = 20;
|
||||
|
||||
/**
|
||||
* The following encoded path was constructed by using the Directions API.
|
||||
* This is the path from the Space Needle to Paramount Theatre, with the mode of transport
|
||||
* set to walking.
|
||||
* Please see the documentation https://developers.google.com/maps/documentation/directions
|
||||
* for more detail.
|
||||
*/
|
||||
static NSString *const kEncodedPathForWalkingDirections =
|
||||
@"ezsaHxkwiVLc@FQ?G@G@GDKBEPED?@@B@FOJSOUDIZk@?cB?w@?iA@yLAs@?IB?Ae@@_A?sACoA?EB??e@?u@A}A@{@`@"
|
||||
@"EBGv@_C\\aA?M?G@WHCFB|@kCRm@DQ?EDB@FZP?E@_@CC?oA?O\\i@j@mAN[DWd@GIq@BA?CBUVcAhA_CLUBDL_@@Bf@"
|
||||
@"eA`@o@|@iBCCRa@DD^aAf@{@`@}@Xc@GIVc@DDj@iANe@x@cBHUACRYNPZQHLDFDCVSB?CGKYHGr@s@r@g@v@o@"
|
||||
@"GUVSBC@FDJJK";
|
||||
|
||||
@implementation StampedPolylinesViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
GMSCameraPosition *defaultCamera = [GMSCameraPosition cameraWithLatitude:kSeattleLatitudeDegrees
|
||||
longitude:kSeattleLongitudeDegrees
|
||||
zoom:kZoom];
|
||||
|
||||
GMSMapView *map = [GMSMapView mapWithFrame:self.view.bounds camera:defaultCamera];
|
||||
map.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
|
||||
[self.view addSubview:map];
|
||||
|
||||
[self addTextureStampedPolylineToMap:map];
|
||||
[self addGradientTextureStampedPolylineToMap:map];
|
||||
[self addSpriteWalkingDotStampedPolylineToMap:map];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a texture stamped polyline and adds it to the supplied map.
|
||||
*
|
||||
* @param map The map to add the polyline to.
|
||||
*/
|
||||
- (void)addTextureStampedPolylineToMap:(GMSMapView *)map {
|
||||
GMSMutablePath *path = [GMSMutablePath path];
|
||||
[path addLatitude:kSeattleLatitudeDegrees + 0.003 longitude:kSeattleLongitudeDegrees - 0.003];
|
||||
[path addLatitude:kSeattleLatitudeDegrees - 0.005 longitude:kSeattleLongitudeDegrees - 0.005];
|
||||
[path addLatitude:kSeattleLatitudeDegrees - 0.007 longitude:kSeattleLongitudeDegrees + 0.001];
|
||||
|
||||
UIImage *_Nonnull stamp = (UIImage *_Nonnull)[UIImage imageNamed:@"voyager"];
|
||||
GMSStrokeStyle *solidStroke = [GMSStrokeStyle solidColor:[UIColor redColor]];
|
||||
solidStroke.stampStyle = [GMSTextureStyle textureStyleWithImage:stamp];
|
||||
|
||||
GMSPolyline *texturePolyline = [GMSPolyline polylineWithPath:path];
|
||||
texturePolyline.map = map;
|
||||
texturePolyline.strokeWidth = kStrokeWidth;
|
||||
texturePolyline.spans = @[ [GMSStyleSpan spanWithStyle:solidStroke] ];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a texture stamped polyline with gradient background and adds it to the supplied map.
|
||||
*
|
||||
* @param map The map to add the polyline to.
|
||||
*/
|
||||
- (void)addGradientTextureStampedPolylineToMap:(GMSMapView *)map {
|
||||
GMSMutablePath *texturePath = [GMSMutablePath path];
|
||||
[texturePath addLatitude:kSeattleLatitudeDegrees - 0.012 longitude:kSeattleLongitudeDegrees];
|
||||
[texturePath addLatitude:kSeattleLatitudeDegrees - 0.012
|
||||
longitude:kSeattleLongitudeDegrees - 0.008];
|
||||
|
||||
UIImage *_Nonnull textureStamp = (UIImage *_Nonnull)[UIImage imageNamed:@"aeroplane"];
|
||||
|
||||
GMSStrokeStyle *gradientStroke = [GMSStrokeStyle gradientFromColor:[UIColor magentaColor]
|
||||
toColor:[UIColor greenColor]];
|
||||
gradientStroke.stampStyle = [GMSTextureStyle textureStyleWithImage:textureStamp];
|
||||
|
||||
GMSPolyline *gradientTexturePolyline = [GMSPolyline polylineWithPath:texturePath];
|
||||
gradientTexturePolyline.strokeWidth = kStrokeWidth * 1.5;
|
||||
gradientTexturePolyline.spans = @[ [GMSStyleSpan spanWithStyle:gradientStroke] ];
|
||||
gradientTexturePolyline.zIndex = 1;
|
||||
gradientTexturePolyline.map = map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a sprite stamped polyline, using walking dots as the sprite, to the supplied map.
|
||||
*
|
||||
* @param map The map to add the polyline to.
|
||||
*/
|
||||
- (void)addSpriteWalkingDotStampedPolylineToMap:(GMSMapView *)map {
|
||||
GMSPath *path = [GMSPath pathFromEncodedPath:kEncodedPathForWalkingDirections];
|
||||
|
||||
UIImage *_Nonnull stamp = (UIImage *_Nonnull)[UIImage imageNamed:@"walking_dot.png"];
|
||||
GMSStrokeStyle *stroke = [GMSStrokeStyle solidColor:[UIColor redColor]];
|
||||
stroke.stampStyle = [GMSSpriteStyle spriteStyleWithImage:stamp];
|
||||
GMSPolyline *polyline = [GMSPolyline polylineWithPath:path];
|
||||
polyline.map = map;
|
||||
polyline.strokeWidth = kStrokeWidth;
|
||||
polyline.spans = @[ [GMSStyleSpan spanWithStyle:stroke] ];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/StructuredGeocoderViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/StructuredGeocoderViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface StructuredGeocoderViewController : UIViewController
|
||||
|
||||
@end
|
||||
95
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/StructuredGeocoderViewController.m
generated
Executable file
95
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/StructuredGeocoderViewController.m
generated
Executable file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/StructuredGeocoderViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@interface StructuredGeocoderViewController () <GMSMapViewDelegate>
|
||||
|
||||
@end
|
||||
|
||||
@implementation StructuredGeocoderViewController {
|
||||
GMSMapView *_mapView;
|
||||
GMSGeocoder *_geocoder;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
|
||||
longitude:151.2086
|
||||
zoom:12];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
_mapView.delegate = self;
|
||||
_geocoder = [[GMSGeocoder alloc] init];
|
||||
|
||||
self.view = _mapView;
|
||||
}
|
||||
|
||||
#pragma mark - GMSMapViewDelegate
|
||||
|
||||
- (void)mapView:(GMSMapView *)mapView didLongPressAtCoordinate:(CLLocationCoordinate2D)coordinate {
|
||||
// On a long press, reverse geocode this location.
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
GMSReverseGeocodeCallback handler = ^(GMSReverseGeocodeResponse *response, NSError *error) {
|
||||
[weakSelf handleResponse:response coordinate:coordinate error:error];
|
||||
};
|
||||
[_geocoder reverseGeocodeCoordinate:coordinate completionHandler:handler];
|
||||
}
|
||||
|
||||
#pragma mark - StructuredGeocoderViewController Private Category
|
||||
|
||||
- (void)handleResponse:(nullable GMSReverseGeocodeResponse *)response
|
||||
coordinate:(CLLocationCoordinate2D)coordinate
|
||||
error:(nullable NSError *)error {
|
||||
GMSAddress *address = response.firstResult;
|
||||
if (address) {
|
||||
NSLog(@"Geocoder result: %@", address);
|
||||
|
||||
GMSMarker *marker = [GMSMarker markerWithPosition:address.coordinate];
|
||||
|
||||
marker.title = address.thoroughfare;
|
||||
|
||||
NSMutableString *snippet = [[NSMutableString alloc] init];
|
||||
if (address.subLocality != NULL) {
|
||||
[snippet appendString:[NSString stringWithFormat:@"subLocality: %@\n", address.subLocality]];
|
||||
}
|
||||
if (address.locality != NULL) {
|
||||
[snippet appendString:[NSString stringWithFormat:@"locality: %@\n", address.locality]];
|
||||
}
|
||||
if (address.administrativeArea != NULL) {
|
||||
[snippet appendString:[NSString stringWithFormat:@"administrativeArea: %@\n",
|
||||
address.administrativeArea]];
|
||||
}
|
||||
if (address.country != NULL) {
|
||||
[snippet appendString:[NSString stringWithFormat:@"country: %@\n", address.country]];
|
||||
}
|
||||
|
||||
marker.snippet = snippet;
|
||||
|
||||
marker.appearAnimation = kGMSMarkerAnimationPop;
|
||||
marker.map = _mapView;
|
||||
_mapView.selectedMarker = marker;
|
||||
} else {
|
||||
NSLog(@"Could not reverse geocode point (%f,%f): %@", coordinate.latitude, coordinate.longitude,
|
||||
error);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/StyledMapViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/StyledMapViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface StyledMapViewController : UIViewController
|
||||
|
||||
@end
|
||||
126
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/StyledMapViewController.m
generated
Executable file
126
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/StyledMapViewController.m
generated
Executable file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/StyledMapViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
static NSString *const kNormalType = @"Normal";
|
||||
static NSString *const kRetroType = @"Retro";
|
||||
static NSString *const kGrayscaleType = @"Grayscale";
|
||||
static NSString *const kNightType = @"Night";
|
||||
static NSString *const kNoPOIsType = @"No business points of interest, no transit";
|
||||
|
||||
@implementation StyledMapViewController {
|
||||
UIBarButtonItem *_barButtonItem;
|
||||
GMSMapView *_mapView;
|
||||
GMSMapStyle *_retroStyle;
|
||||
GMSMapStyle *_grayscaleStyle;
|
||||
GMSMapStyle *_nightStyle;
|
||||
GMSMapStyle *_noPOIsStyle;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
|
||||
// Error handling is skipped here for brevity, however it is recommended that you look at the
|
||||
// error returned from |styleWithContentsOfFileURL:error:| if it returns nil. This error will
|
||||
// provide information on why your style was not able to be loaded.
|
||||
|
||||
NSURL *retroURL = [[NSBundle mainBundle] URLForResource:@"mapstyle-retro" withExtension:@"json"];
|
||||
_retroStyle = [GMSMapStyle styleWithContentsOfFileURL:retroURL error:NULL];
|
||||
|
||||
NSURL *grayscaleURL = [[NSBundle mainBundle] URLForResource:@"mapstyle-silver"
|
||||
withExtension:@"json"];
|
||||
_grayscaleStyle = [GMSMapStyle styleWithContentsOfFileURL:grayscaleURL error:NULL];
|
||||
|
||||
NSURL *nightURL = [[NSBundle mainBundle] URLForResource:@"mapstyle-night" withExtension:@"json"];
|
||||
_nightStyle = [GMSMapStyle styleWithContentsOfFileURL:nightURL error:NULL];
|
||||
|
||||
NSString *noPOIsString = @" [\n"
|
||||
" {\n"
|
||||
" \"featureType\": \"poi.business\",\n"
|
||||
" \"elementType\": \"all\",\n"
|
||||
" \"stylers\": [\n"
|
||||
" {\n"
|
||||
" \"visibility\": \"off\"\n"
|
||||
" }\n"
|
||||
" ]\n"
|
||||
" },\n"
|
||||
" {\n"
|
||||
" \"featureType\": \"transit\",\n"
|
||||
" \"elementType\": \"all\",\n"
|
||||
" \"stylers\": [\n"
|
||||
" {\n"
|
||||
" \"visibility\": \"off\"\n"
|
||||
" }\n"
|
||||
" ]\n"
|
||||
" }\n"
|
||||
" ]";
|
||||
_noPOIsStyle = [GMSMapStyle styleWithJSONString:noPOIsString error:NULL];
|
||||
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
|
||||
longitude:151.2086
|
||||
zoom:12];
|
||||
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
self.view = _mapView;
|
||||
|
||||
_mapView.mapStyle = _retroStyle;
|
||||
|
||||
UIBarButtonItem *styleButton = [[UIBarButtonItem alloc] initWithTitle:@"Style"
|
||||
style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(changeMapStyle:)];
|
||||
self.navigationItem.rightBarButtonItem = styleButton;
|
||||
self.navigationItem.title = kRetroType;
|
||||
}
|
||||
|
||||
- (UIAlertAction *_Nonnull)actionWithTitle:(nonnull NSString *)title
|
||||
style:(nullable GMSMapStyle *)style {
|
||||
__weak __typeof__(self) weakSelf = self;
|
||||
return [UIAlertAction actionWithTitle:title
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction *_Nonnull action) {
|
||||
__strong __typeof__(self) strongSelf = weakSelf;
|
||||
if (strongSelf) {
|
||||
strongSelf->_mapView.mapStyle = style;
|
||||
strongSelf.navigationItem.title = title;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)changeMapStyle:(UIBarButtonItem *)sender {
|
||||
UIAlertController *alert =
|
||||
[UIAlertController alertControllerWithTitle:@"Select map style"
|
||||
message:nil
|
||||
preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
[alert addAction:[self actionWithTitle:kRetroType style:_retroStyle]];
|
||||
[alert addAction:[self actionWithTitle:kGrayscaleType style:_grayscaleStyle]];
|
||||
[alert addAction:[self actionWithTitle:kNightType style:_nightStyle]];
|
||||
[alert addAction:[self actionWithTitle:kNormalType style:nil]];
|
||||
[alert addAction:[self actionWithTitle:kNoPOIsType style:_noPOIsStyle]];
|
||||
[alert addAction:[UIAlertAction actionWithTitle:@"Cancel"
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:nil]];
|
||||
alert.popoverPresentationController.barButtonItem = sender;
|
||||
[self presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/TileLayerViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/TileLayerViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface TileLayerViewController : UIViewController
|
||||
|
||||
@end
|
||||
87
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/TileLayerViewController.m
generated
Executable file
87
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/TileLayerViewController.m
generated
Executable file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/TileLayerViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@implementation TileLayerViewController {
|
||||
UISegmentedControl *_switcher;
|
||||
GMSMapView *_mapView;
|
||||
GMSTileLayer *_tileLayer;
|
||||
NSInteger _floor;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:37.78318
|
||||
longitude:-122.403874
|
||||
zoom:18];
|
||||
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
_mapView.buildingsEnabled = NO;
|
||||
_mapView.indoorEnabled = NO;
|
||||
self.view = _mapView;
|
||||
|
||||
// The possible floors that might be shown.
|
||||
//
|
||||
NSArray<NSString *> *types = @[ @"1", @"3" ];
|
||||
|
||||
// Create a UISegmentedControl that is the navigationItem's titleView.
|
||||
_switcher = [[UISegmentedControl alloc] initWithItems:types];
|
||||
_switcher.selectedSegmentIndex = 0;
|
||||
_switcher.autoresizingMask = UIViewAutoresizingFlexibleWidth;
|
||||
_switcher.frame = CGRectMake(0, 0, 300, _switcher.frame.size.height);
|
||||
self.navigationItem.titleView = _switcher;
|
||||
|
||||
// Listen to touch events on the UISegmentedControl, force initial update.
|
||||
[_switcher addTarget:self
|
||||
action:@selector(didChangeSwitcher)
|
||||
forControlEvents:UIControlEventValueChanged];
|
||||
[self didChangeSwitcher];
|
||||
}
|
||||
|
||||
- (void)viewWillLayoutSubviews {
|
||||
[super viewWillLayoutSubviews];
|
||||
// Re-show level picker.
|
||||
self.navigationItem.titleView = nil;
|
||||
self.navigationItem.titleView = _switcher;
|
||||
}
|
||||
|
||||
- (void)didChangeSwitcher {
|
||||
NSString *title = [_switcher titleForSegmentAtIndex:_switcher.selectedSegmentIndex];
|
||||
NSInteger floor = [title integerValue];
|
||||
if (_floor != floor) {
|
||||
// Clear existing tileLayer, if any.
|
||||
_tileLayer.map = nil;
|
||||
|
||||
// Create a new GMSTileLayer with the new floor choice.
|
||||
GMSTileURLConstructor urls = ^(NSUInteger x, NSUInteger y, NSUInteger zoom) {
|
||||
NSString *url = [NSString
|
||||
stringWithFormat:@"https://www.gstatic.com/io2010maps/tiles/9/L%ld_%lu_%lu_%lu.png",
|
||||
(long)floor, (unsigned long)zoom, (unsigned long)x, (unsigned long)y];
|
||||
return [NSURL URLWithString:url];
|
||||
};
|
||||
_tileLayer = [GMSURLTileLayer tileLayerWithURLConstructor:urls];
|
||||
_tileLayer.map = _mapView;
|
||||
_floor = floor;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/TrafficMapViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/TrafficMapViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface TrafficMapViewController : UIViewController
|
||||
|
||||
@end
|
||||
37
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/TrafficMapViewController.m
generated
Executable file
37
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/TrafficMapViewController.m
generated
Executable file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/TrafficMapViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
@implementation TrafficMapViewController
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
|
||||
longitude:151.2086
|
||||
zoom:12];
|
||||
|
||||
GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
mapView.trafficEnabled = YES;
|
||||
self.view = mapView;
|
||||
}
|
||||
|
||||
@end
|
||||
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/VisibleRegionViewController.h
generated
Executable file
20
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/VisibleRegionViewController.h
generated
Executable file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface VisibleRegionViewController : UIViewController
|
||||
|
||||
@end
|
||||
78
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/VisibleRegionViewController.m
generated
Executable file
78
iosApp/Pods/GoogleMaps/Example/GoogleMapsXCFrameworkDemos/Samples/VisibleRegionViewController.m
generated
Executable file
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright 2016 Google LLC. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
|
||||
* file except in compliance with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under
|
||||
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
|
||||
* ANY KIND, either express or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
#import "GoogleMapsXCFrameworkDemos/Samples/VisibleRegionViewController.h"
|
||||
|
||||
#if __has_feature(modules)
|
||||
@import GoogleMaps;
|
||||
#else
|
||||
#import <GoogleMaps/GoogleMaps.h>
|
||||
#endif
|
||||
|
||||
static const CGFloat kOverlayHeight = 140.0f;
|
||||
|
||||
@implementation VisibleRegionViewController {
|
||||
GMSMapView *_mapView;
|
||||
UIView *_overlay;
|
||||
UIBarButtonItem *_flyInButton;
|
||||
}
|
||||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-37.81969
|
||||
longitude:144.966085
|
||||
zoom:4];
|
||||
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
|
||||
|
||||
// Enable my location button to show more UI components updating.
|
||||
_mapView.settings.myLocationButton = YES;
|
||||
_mapView.myLocationEnabled = YES;
|
||||
_mapView.padding = UIEdgeInsetsMake(0, 0, kOverlayHeight, 0);
|
||||
self.view = _mapView;
|
||||
|
||||
// Create a button that, when pressed, causes an overlaying view to fly-in/out.
|
||||
_flyInButton = [[UIBarButtonItem alloc] initWithTitle:@"Toggle Overlay"
|
||||
style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(didTapFlyIn)];
|
||||
self.navigationItem.rightBarButtonItem = _flyInButton;
|
||||
|
||||
CGRect overlayFrame = CGRectMake(0, -kOverlayHeight, 0, kOverlayHeight);
|
||||
_overlay = [[UIView alloc] initWithFrame:overlayFrame];
|
||||
_overlay.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
|
||||
|
||||
_overlay.backgroundColor = [UIColor colorWithHue:0.0 saturation:1.0 brightness:1.0 alpha:0.5];
|
||||
[self.view addSubview:_overlay];
|
||||
}
|
||||
|
||||
- (void)didTapFlyIn {
|
||||
UIEdgeInsets padding = _mapView.padding;
|
||||
|
||||
[UIView animateWithDuration:2.0
|
||||
animations:^{
|
||||
CGSize size = self.view.bounds.size;
|
||||
if (padding.bottom == 0.0f) {
|
||||
self->_overlay.frame =
|
||||
CGRectMake(0, size.height - kOverlayHeight, size.width, kOverlayHeight);
|
||||
self->_mapView.padding = UIEdgeInsetsMake(0, 0, kOverlayHeight, 0);
|
||||
} else {
|
||||
self->_overlay.frame =
|
||||
CGRectMake(0, self->_mapView.bounds.size.height, size.width, 0);
|
||||
self->_mapView.padding = UIEdgeInsetsZero;
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user