Prevent small js error
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.2.8-beta-20180314-2231" 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.2.8-beta-20180314-2252" 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/GoogleMapsViewController.m
src/ios/GoogleMaps/GoogleMapsViewController.m
- (void)mapView:(GMSMapView *)mapView didTapPOIWithPlaceID:(NSString *)placeID name:(NSString *)name location:(CLLocationCoordinate2D)location {
NSString* jsString = [NSString
- stringWithFormat:@"javascript:plugin.google.maps['%@']({evtName: '%@', callback: '_onMapEvent', args: ['%@', '%@', new plugin.google.maps.LatLng(%f,%f)]});",
- self.mapId, @"poi_click", placeID, name, location.latitude, location.longitude];
+ stringWithFormat:@"javascript:if('%@' in plugin.google.maps){plugin.google.maps['%@']({evtName: '%@', callback: '_onMapEvent', args: ['%@', '%@', new plugin.google.maps.LatLng(%f,%f)]});}",
+ self.mapId, self.mapId, @"poi_click", placeID, name, location.latitude, location.longitude];
[self execJS:jsString];
}
- (BOOL)didTapMyLocationButtonForMapView:(GMSMapView *)mapView {
NSString* jsString = [NSString
- stringWithFormat:@"javascript:plugin.google.maps['%@']({evtName: '%@', callback: '_onMapEvent', args: []});",
- self.mapId, @"my_location_button_click"];
+ stringWithFormat:@"javascript:if('%@' in plugin.google.maps){plugin.google.maps['%@']({evtName: '%@', callback: '_onMapEvent', args: []});}",
+ self.mapId, self.mapId, @"my_location_button_click"];
[self execJS:jsString];
return NO;
}
NSString* sourceArrayString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSString* jsString = [NSString
- stringWithFormat:@"javascript:plugin.google.maps['%@']({evtName: '%@', callback: '_onMapEvent', args: [%@]});",
- self.mapId, @"my_location_click", sourceArrayString];
+ stringWithFormat:@"javascript:if('%@' in plugin.google.maps){plugin.google.maps['%@']({evtName: '%@', callback: '_onMapEvent', args: [%@]});}",
+ self.mapId, self.mapId, @"my_location_click", sourceArrayString];
[self execJS:jsString];
}
CGPoint point = [self.map.projection
pointForCoordinate:CLLocationCoordinate2DMake(position.latitude, position.longitude)];
NSString* jsString = [NSString
- stringWithFormat:@"javascript:plugin.google.maps['%@']({evtName: 'syncPosition', callback: '_onSyncInfoWndPosition', args: [{x: %f, y: %f}]});",
- self.mapId, point.x, point.y ];
+ stringWithFormat:@"javascript:if('%@' in plugin.google.maps){plugin.google.maps['%@']({evtName: 'syncPosition', callback: '_onSyncInfoWndPosition', args: [{x: %f, y: %f}]});}",
+ self.mapId, self.mapId, point.x, point.y ];
[self execJS:jsString];
}
{
NSString* jsString = [NSString
- stringWithFormat:@"javascript:plugin.google.maps['%@']({evtName: '%@', callback: '_onMapEvent', args: []});",
- self.mapId, eventName];
+ stringWithFormat:@"javascript:if('%@' in plugin.google.maps){plugin.google.maps['%@']({evtName: '%@', callback: '_onMapEvent', args: []});}",
+ self.mapId, self.mapId, eventName];
[self execJS:jsString];
}
{
NSString* jsString = [NSString
- stringWithFormat:@"javascript:plugin.google.maps['%@']({evtName: '%@', callback: '_onMapEvent', args: [new plugin.google.maps.LatLng(%f,%f)]});",
- self.mapId, eventName, coordinate.latitude, coordinate.longitude];
+ stringWithFormat:@"javascript:if('%@' in plugin.google.maps){plugin.google.maps['%@']({evtName: '%@', callback: '_onMapEvent', args: [new plugin.google.maps.LatLng(%f,%f)]});}",
+ self.mapId, self.mapId, eventName, coordinate.latitude, coordinate.longitude];
[self execJS:jsString];
}
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:json options:0 error:nil];
NSString* sourceArrayString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSString* jsString = [NSString
- stringWithFormat:@"javascript:plugin.google.maps['%@']({evtName: '%@', callback: '_onCameraEvent', args: [%@]});",
- self.mapId, eventName, sourceArrayString];
+ stringWithFormat:@"javascript:if('%@' in plugin.google.maps){plugin.google.maps['%@']({evtName: '%@', callback: '_onCameraEvent', args: [%@]});}",
+ self.mapId, self.mapId, eventName, sourceArrayString];
[self execJS:jsString];
[self syncInfoWndPosition];
// Get the marker plugin
NSString* jsString = [NSString
- stringWithFormat:@"javascript:plugin.google.maps['%@']({evtName: '%@', callback: '_onClusterEvent', args: ['%@', '%@', new plugin.google.maps.LatLng(%f, %f)]});",
- self.mapId, eventName, clusterId, markerId,
+ stringWithFormat:@"javascript:if('%@' in plugin.google.maps){plugin.google.maps['%@']({evtName: '%@', callback: '_onClusterEvent', args: ['%@', '%@', new plugin.google.maps.LatLng(%f, %f)]});}",
+ self.mapId, self.mapId, eventName, clusterId, markerId,
marker.position.latitude,
marker.position.longitude];
[self execJS:jsString];
NSString *markerId = [tmp objectAtIndex:([tmp count] - 1)];
NSString* jsString = [NSString
- stringWithFormat:@"javascript:plugin.google.maps['%@']({evtName: '%@', callback: '_onMarkerEvent', args: ['%@', new plugin.google.maps.LatLng(%f, %f)]});",
- self.mapId, eventName, markerId,
+ stringWithFormat:@"javascript:if('%@' in plugin.google.maps){plugin.google.maps['%@']({evtName: '%@', callback: '_onMarkerEvent', args: ['%@', new plugin.google.maps.LatLng(%f, %f)]});}",
+ self.mapId, self.mapId, eventName, markerId,
marker.position.latitude,
marker.position.longitude];
[self execJS:jsString];
- (void)triggerOverlayEvent: (NSString *)eventName overlayId:(NSString*)overlayId coordinate:(CLLocationCoordinate2D)coordinate
{
NSString* jsString = [NSString
- stringWithFormat:@"javascript:plugin.google.maps['%@']({evtName: '%@', callback: '_onOverlayEvent', args: ['%@', new plugin.google.maps.LatLng(%f, %f)]});",
- self.mapId, eventName, overlayId, coordinate.latitude, coordinate.longitude];
+ stringWithFormat:@"javascript:if('%@' in plugin.google.maps){plugin.google.maps['%@']({evtName: '%@', callback: '_onOverlayEvent', args: ['%@', new plugin.google.maps.LatLng(%f, %f)]});}",
+ self.mapId, self.mapId, eventName, overlayId, coordinate.latitude, coordinate.longitude];
[self execJS:jsString];
}
}
//Notify to the JS
NSString* jsString = [NSString
- stringWithFormat:@"javascript:plugin.google.maps['%@']({evtName: 'indoor_building_focused', callback: '_onMapEvent'});",
- self.mapId];
+ stringWithFormat:@"javascript:if('%@' in plugin.google.maps){plugin.google.maps['%@']({evtName: 'indoor_building_focused', callback: '_onMapEvent'});}",
+ self.mapId, self.mapId];
[self execJS:jsString];
}
//Notify to the JS
NSString* jsString = [NSString
- stringWithFormat:@"javascript:plugin.google.maps['%@']({evtName: 'indoor_level_activated', callback: '_onMapEvent', args: [%@]});",
- self.mapId, JSONstring];
+ stringWithFormat:@"javascript:if('%@' in plugin.google.maps){plugin.google.maps['%@']({evtName: 'indoor_level_activated', callback: '_onMapEvent', args: [%@]});}",
+ self.mapId, self.mapId, JSONstring];
[self execJS:jsString];
}

Prevent small js error