Bug fix: setCameraZoom crashes Xcode simulator
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.0.0-beta3-20170830-1054" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
+<plugin id="cordova-plugin-googlemaps" version="2.0.0-beta3-20170830-1106" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<name>cordova-plugin-googlemaps</name>
<js-module name="BaseClass" src="www/BaseClass.js">
<runs />

MODIFY
src/ios/GoogleMaps/PluginMap.m
src/ios/GoogleMaps/PluginMap.m
}
- (void)setMyLocationEnabled:(CDVInvokedUrlCommand *)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
- Boolean isEnabled = [[command.arguments objectAtIndex:0] boolValue];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
+ Boolean isEnabled = [[command.arguments objectAtIndex:0] boolValue];
self.mapCtrl.map.settings.myLocationButton = isEnabled;
self.mapCtrl.map.myLocationEnabled = isEnabled;
}];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
- }];
}
- (void)setIndoorEnabled:(CDVInvokedUrlCommand *)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
- Boolean isEnabled = [[command.arguments objectAtIndex:0] boolValue];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
+ Boolean isEnabled = [[command.arguments objectAtIndex:0] boolValue];
self.mapCtrl.map.settings.indoorPicker = isEnabled;
self.mapCtrl.map.indoorEnabled = isEnabled;
}];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
- }];
}
- (void)setTrafficEnabled:(CDVInvokedUrlCommand *)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
- Boolean isEnabled = [[command.arguments objectAtIndex:0] boolValue];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
+ Boolean isEnabled = [[command.arguments objectAtIndex:0] boolValue];
self.mapCtrl.map.trafficEnabled = isEnabled;
}];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
- }];
}
- (void)setCompassEnabled:(CDVInvokedUrlCommand *)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
- Boolean isEnabled = [[command.arguments objectAtIndex:0] boolValue];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
+ Boolean isEnabled = [[command.arguments objectAtIndex:0] boolValue];
self.mapCtrl.map.settings.compassButton = isEnabled;
}];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
- }];
}
- (void)setVisible:(CDVInvokedUrlCommand *)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
- BOOL isVisible = [[command.arguments objectAtIndex:0] boolValue];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
+ BOOL isVisible = [[command.arguments objectAtIndex:0] boolValue];
[self.mapCtrl.view setHidden:!isVisible];
}];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
- }];
}
- (void)setCameraTilt:(CDVInvokedUrlCommand *)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
+ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
double angle = [[command.arguments objectAtIndex:0] doubleValue];
if (angle >=0 && angle <= 90) {
GMSCameraPosition *camera = self.mapCtrl.map.camera;
bearing:camera.bearing
viewingAngle:angle];
- [[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self.mapCtrl.map setCamera:camera];
- }];
}
}
- (void)setCameraBearing:(CDVInvokedUrlCommand *)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
+ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
double bearing = [[command.arguments objectAtIndex:0] doubleValue];
GMSCameraPosition *camera = self.mapCtrl.map.camera;
camera = [GMSCameraPosition cameraWithLatitude:camera.target.latitude
bearing:bearing
viewingAngle:camera.viewingAngle];
- [[NSOperationQueue mainQueue] addOperationWithBlock:^{
+
[self.mapCtrl.map setCamera:camera];
- }];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
}];
}
- (void)setAllGesturesEnabled:(CDVInvokedUrlCommand *)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
- Boolean isEnabled = [[command.arguments objectAtIndex:0] boolValue];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
+ Boolean isEnabled = [[command.arguments objectAtIndex:0] boolValue];
[self.mapCtrl.map.settings setAllGesturesEnabled:isEnabled];
}];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
- }];
}
* Change the zoom level
*/
- (void)setCameraZoom:(CDVInvokedUrlCommand *)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
- float zoom = [[command.arguments objectAtIndex:0] floatValue];
- CLLocationCoordinate2D center = [self.mapCtrl.map.projection coordinateForPoint:self.mapCtrl.map.center];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
+ float zoom = [[command.arguments objectAtIndex:0] floatValue];
+ CLLocationCoordinate2D center = [self.mapCtrl.map.projection coordinateForPoint:self.mapCtrl.map.center];
[self.mapCtrl.map setCamera:[GMSCameraPosition cameraWithTarget:center zoom:zoom]];
}];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
- }];
}
/**
* Pan by
*/
- (void)panBy:(CDVInvokedUrlCommand *)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
+ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
int x = [[command.arguments objectAtIndex:0] intValue];
int y = [[command.arguments objectAtIndex:1] intValue];
-
- [[NSOperationQueue mainQueue] addOperationWithBlock:^{
[self.mapCtrl.map animateWithCameraUpdate:[GMSCameraUpdate scrollByX:x * -1 Y:y * -1]];
}];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
- }];
}
/**
- (void)setActiveMarkerId:(CDVInvokedUrlCommand*)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
NSString *markerId = [command.arguments objectAtIndex:0];
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
[(CDVCommandDelegateImpl *)self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
- }];
}
- (void)toDataURL:(CDVInvokedUrlCommand *)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
NSDictionary *opts = [command.arguments objectAtIndex:0];
BOOL uncompress = NO;
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}];
- }];
}
/**
*/
- (void)fromLatLngToPoint:(CDVInvokedUrlCommand*)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
- float latitude = [[command.arguments objectAtIndex:0] floatValue];
- float longitude = [[command.arguments objectAtIndex:1] floatValue];
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
+ float latitude = [[command.arguments objectAtIndex:0] floatValue];
+ float longitude = [[command.arguments objectAtIndex:1] floatValue];
CGPoint point = [self.mapCtrl.map.projection
pointForCoordinate:CLLocationCoordinate2DMake(latitude, longitude)];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}];
- }];
}
/**
*/
- (void)fromPointToLatLng:(CDVInvokedUrlCommand*)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
+ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
float pointX = [[command.arguments objectAtIndex:0] floatValue];
float pointY = [[command.arguments objectAtIndex:1] floatValue];
-
- [[NSOperationQueue mainQueue] addOperationWithBlock:^{
CLLocationCoordinate2D latLng = [self.mapCtrl.map.projection
coordinateForPoint:CGPointMake(pointX, pointY)];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}];
- }];
}
- (void)_setOptions:(NSDictionary *)initOptions requestMethod:(NSString *)requestMethod command:(CDVInvokedUrlCommand *)command {
}
- (void)getFocusedBuilding:(CDVInvokedUrlCommand*)command {
- [self.mapCtrl.executeQueue addOperationWithBlock:^{
[[NSOperationQueue mainQueue] addOperationWithBlock:^{
GMSIndoorBuilding *building = self.mapCtrl.map.indoorDisplay.activeBuilding;
if (building != nil || [building.levels count] == 0) {
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}];
}];
- }];
}
@end

Bug fix: setCameraZoom crashes Xcode simulator #1685