Skip to content

Commit 541eb72

Browse files
author
masashiGMS
committed
temporally save
1 parent 7fd0389 commit 541eb72

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

src/ios/GoogleMaps/GoogleMapsViewController.m

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ - (void)viewDidLoad
5555
//------------------
5656

5757
//Intial camera position
58+
/*
5859
NSDictionary *cameraOpts = [initOptions objectForKey:@"camera"];
5960
NSMutableDictionary *latLng = [NSMutableDictionary dictionary];
6061
[latLng setObject:[NSNumber numberWithFloat:0.0f] forKey:@"lat"];
@@ -71,6 +72,63 @@ - (void)viewDidLoad
7172
zoom: [[cameraOpts valueForKey:@"zoom"] floatValue]
7273
bearing:[[cameraOpts objectForKey:@"bearing"] doubleValue]
7374
viewingAngle:[[cameraOpts objectForKey:@"tilt"] doubleValue]];
75+
*/
76+
77+
78+
NSDictionary *cameraOpts = [initOptions objectForKey:@"camera"];
79+
NSMutableDictionary *latLng = [NSMutableDictionary dictionary];
80+
[latLng setObject:[NSNumber numberWithFloat:0.0f] forKey:@"lat"];
81+
[latLng setObject:[NSNumber numberWithFloat:0.0f] forKey:@"lng"];
82+
float latitude;
83+
float longitude;
84+
GMSCameraPosition *camera;
85+
GMSCameraPosition *initCamera;
86+
87+
if ([cameraOpts objectForKey:@"target"]) {
88+
NSString *targetClsName = [[cameraOpts objectForKey:@"target"] className];
89+
if ([targetClsName isEqualToString:@"__NSCFArray"] || [targetClsName isEqualToString:@"__NSArrayM"] ) {
90+
int i = 0;
91+
NSArray *latLngList = [cameraOpts objectForKey:@"target"];
92+
GMSMutablePath *path = [GMSMutablePath path];
93+
for (i = 0; i < [latLngList count]; i++) {
94+
latLng = [latLngList objectAtIndex:i];
95+
NSLog(@"---->latLng=%@", latLng);
96+
latitude = [[latLng valueForKey:@"lat"] floatValue];
97+
longitude = [[latLng valueForKey:@"lng"] floatValue];
98+
[path addLatitude:latitude longitude:longitude];
99+
}
100+
float scale = 1;
101+
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
102+
scale = [[UIScreen mainScreen] scale];
103+
}
104+
[[UIScreen mainScreen] scale];
105+
106+
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithPath:path];
107+
108+
NSLog(@"---->bounds=%f,%f - ,%f,%f", bounds.southWest.latitude,bounds.southWest.longitude, bounds.northEast.latitude, bounds.northEast.longitude);
109+
110+
initCamera = [self.map cameraForBounds:bounds insets:UIEdgeInsetsMake(10 * scale, 10* scale, 10* scale, 10* scale)];
111+
112+
113+
} else {
114+
latLng = [cameraOpts objectForKey:@"target"];
115+
latitude = [[latLng valueForKey:@"lat"] floatValue];
116+
longitude = [[latLng valueForKey:@"lng"] floatValue];
117+
118+
camera = [GMSCameraPosition cameraWithLatitude:latitude
119+
longitude:longitude
120+
zoom:[[cameraOpts valueForKey:@"zoom"] floatValue]
121+
bearing:[[cameraOpts objectForKey:@"bearing"] doubleValue]
122+
viewingAngle:[[cameraOpts objectForKey:@"tilt"] doubleValue]];
123+
}
124+
} else {
125+
camera = [GMSCameraPosition
126+
cameraWithLatitude: [[latLng valueForKey:@"lat"] floatValue]
127+
longitude: [[latLng valueForKey:@"lng"] floatValue]
128+
zoom: [[cameraOpts valueForKey:@"zoom"] floatValue]
129+
bearing:[[cameraOpts objectForKey:@"bearing"] doubleValue]
130+
viewingAngle:[[cameraOpts objectForKey:@"tilt"] doubleValue]];
131+
}
74132

75133
CGRect pluginRect = self.view.frame;
76134
int marginBottom = 0;

0 commit comments

Comments
 (0)