From 7a7e630a2fa2fb6512098fc41b956d12b1efc8e9 Mon Sep 17 00:00:00 2001 From: wf9a5m75 Date: Fri, 11 Jul 2014 13:09:26 -0700 Subject: [PATCH] Modified indent spaces --- .../plugin/google/maps/GoogleMaps.java | 217 +++++++++--------- src/ios/GoogleMaps/GoogleMapsViewController.m | 32 +-- src/ios/GoogleMaps/Polyline.m | 2 +- 3 files changed, 123 insertions(+), 128 deletions(-) diff --git a/src/android/plugin/google/maps/GoogleMaps.java b/src/android/plugin/google/maps/GoogleMaps.java index 7ddfd8b16..c04390c75 100644 --- a/src/android/plugin/google/maps/GoogleMaps.java +++ b/src/android/plugin/google/maps/GoogleMaps.java @@ -3,8 +3,8 @@ import java.lang.reflect.Constructor; import java.util.HashMap; import java.util.Iterator; -import java.util.Set; import java.util.List; +import java.util.Set; import org.apache.cordova.CallbackContext; import org.apache.cordova.CordovaInterface; @@ -68,13 +68,14 @@ import com.google.android.gms.maps.MapsInitializer; import com.google.android.gms.maps.model.CameraPosition; import com.google.android.gms.maps.model.CameraPosition.Builder; +import com.google.android.gms.maps.model.Circle; +import com.google.android.gms.maps.model.GroundOverlay; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLngBounds; import com.google.android.gms.maps.model.Marker; import com.google.android.gms.maps.model.Polygon; -import com.google.android.gms.maps.model.Circle; -import com.google.android.gms.maps.model.GroundOverlay; +@SuppressWarnings("deprecation") public class GoogleMaps extends CordovaPlugin implements View.OnClickListener, OnMarkerClickListener, OnInfoWindowClickListener, OnMapClickListener, OnMapLongClickListener, OnCameraChangeListener, OnMapLoadedCallback, OnMarkerDragListener, @@ -428,7 +429,6 @@ public void onClick(DialogInterface dialog,int id) { callbackContext.success(); return; } - @SuppressWarnings("deprecation") private int contentToView(long d) { return Math.round(d * webView.getScale()); } @@ -458,7 +458,6 @@ private void loadPlugin(String serviceName) { } } - @SuppressWarnings("unused") private Boolean getLicenseInfo(JSONArray args, CallbackContext callbackContext) { String msg = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(activity); callbackContext.success(msg); @@ -600,7 +599,6 @@ private void resizeMap(JSONArray args, CallbackContext callbackContext) throws J callbackContext.success(); } - @SuppressWarnings("deprecation") private void updateMapViewLayout() { try { int divW = contentToView(mapDivLayoutJSON.getLong("width") ); @@ -859,7 +857,7 @@ private void onCircleEvent(final String eventName, final Circle circle) { */ private void onGroundOverlayEvent(final String eventName, final GroundOverlay groundOverlay) { String groundOverlayId = "groundOverlay_" + groundOverlay.getId(); - + PluginEntry groundOverlayPlugin = this.plugins.get("GroundOverlay"); PluginGroundOverlay groundOverlayClass = (PluginGroundOverlay) groundOverlayPlugin.plugin; if (groundOverlayClass.objects.containsKey(groundOverlayId)) { @@ -943,57 +941,54 @@ public void onMapLongClick(LatLng point) { * @param point */ public void onMapClick(LatLng point) { - boolean hitPoly = false; - - // Loop through all polygons to check if within the touch point - PluginEntry polygonPlugin = this.plugins.get("Polygon"); - if(polygonPlugin != null) { - PluginPolygon polygonClass = (PluginPolygon) polygonPlugin.plugin; - - for (HashMap.Entry entry : polygonClass.objects.entrySet()) { - String key = entry.getKey(); - Polygon polygon = (Polygon) entry.getValue(); - if(this.polygonContainsPoint(polygon, point)) { - hitPoly = true; - this.onPolygonEvent("overlay_click", polygon); - } - } - } - - // Loop through all circles to check if within the touch point - PluginEntry circlePlugin = this.plugins.get("Circle"); - if(circlePlugin != null) { - PluginCircle circleClass = (PluginCircle) circlePlugin.plugin; - - for (HashMap.Entry entry : circleClass.objects.entrySet()) { - String key = entry.getKey(); - Circle circle = (Circle) entry.getValue(); - if(this.circleContainsPoint(circle, point)) { - hitPoly = true; - this.onCircleEvent("overlay_click", circle); - } - } - } - - // Loop through ground overlays to check if within the touch point - PluginEntry groundOverlayPlugin = this.plugins.get("GroundOverlay"); - if(groundOverlayPlugin != null) { - PluginGroundOverlay groundOverlayClass = (PluginGroundOverlay) groundOverlayPlugin.plugin; - - for (HashMap.Entry entry : groundOverlayClass.objects.entrySet()) { - String key = entry.getKey(); - GroundOverlay groundOverlay = (GroundOverlay) entry.getValue(); - if(this.groundOverlayContainsPoint(groundOverlay, point)) { - hitPoly = true; - this.onGroundOverlayEvent("overlay_click", groundOverlay); - } - } - } - - // Only emit click event if no polygons hit - if(!hitPoly) { - this.onMapEvent("click", point); - } + boolean hitPoly = false; + + // Loop through all polygons to check if within the touch point + PluginEntry polygonPlugin = this.plugins.get("Polygon"); + if(polygonPlugin != null) { + PluginPolygon polygonClass = (PluginPolygon) polygonPlugin.plugin; + + for (HashMap.Entry entry : polygonClass.objects.entrySet()) { + Polygon polygon = (Polygon) entry.getValue(); + if(this.polygonContainsPoint(polygon, point)) { + hitPoly = true; + this.onPolygonEvent("overlay_click", polygon); + } + } + } + + // Loop through all circles to check if within the touch point + PluginEntry circlePlugin = this.plugins.get("Circle"); + if(circlePlugin != null) { + PluginCircle circleClass = (PluginCircle) circlePlugin.plugin; + + for (HashMap.Entry entry : circleClass.objects.entrySet()) { + Circle circle = (Circle) entry.getValue(); + if(this.circleContainsPoint(circle, point)) { + hitPoly = true; + this.onCircleEvent("overlay_click", circle); + } + } + } + + // Loop through ground overlays to check if within the touch point + PluginEntry groundOverlayPlugin = this.plugins.get("GroundOverlay"); + if(groundOverlayPlugin != null) { + PluginGroundOverlay groundOverlayClass = (PluginGroundOverlay) groundOverlayPlugin.plugin; + + for (HashMap.Entry entry : groundOverlayClass.objects.entrySet()) { + GroundOverlay groundOverlay = (GroundOverlay) entry.getValue(); + if(this.groundOverlayContainsPoint(groundOverlay, point)) { + hitPoly = true; + this.onGroundOverlayEvent("overlay_click", groundOverlay); + } + } + } + + // Only emit click event if no polygons hit + if(!hitPoly) { + this.onMapEvent("click", point); + } } /** @@ -1002,26 +997,26 @@ public void onMapClick(LatLng point) { * @param point */ private boolean polygonContainsPoint(Polygon polygon, LatLng point) { - int crossings = 0; - List path = polygon.getPoints(); - - for (int i = 0; i < path.size(); i++) { - LatLng a = path.get(i); - - int j = i + 1; - if(j >= path.size()) { - j = 0; - } - - LatLng b = path.get(j); - - if(this.rayCrossesSegment(point, a, b)) { - crossings++; - } - - } - - return (crossings % 2 == 1); + int crossings = 0; + List path = polygon.getPoints(); + + for (int i = 0; i < path.size(); i++) { + LatLng a = path.get(i); + + int j = i + 1; + if(j >= path.size()) { + j = 0; + } + + LatLng b = path.get(j); + + if(this.rayCrossesSegment(point, a, b)) { + crossings++; + } + + } + + return (crossings % 2 == 1); } /** @@ -1031,21 +1026,21 @@ private boolean polygonContainsPoint(Polygon polygon, LatLng point) { * @param b */ private boolean rayCrossesSegment(LatLng point, LatLng a, LatLng b) { - double pX = point.latitude; - double pY = point.longitude; - double aX = a.latitude; - double aY = a.longitude; - double bX = b.latitude; - double bY = b.longitude; - if ( (aY>pY && bY>pY) || (aYpY && bY>pY) || (aY pX; + return x > pX; } /** @@ -1054,22 +1049,22 @@ private boolean rayCrossesSegment(LatLng point, LatLng a, LatLng b) { * @param point */ private boolean circleContainsPoint(Circle circle, LatLng point) { - double r = circle.getRadius(); - LatLng center = circle.getCenter(); - double cX = center.latitude; - double cY = center.longitude; - double pX = point.latitude; - double pY = point.longitude; - - float[] results = new float[1]; - - Location.distanceBetween(cX, cY, pX, pY, results); - - if(results[0] < r) { - return true; - } else { - return false; - } + double r = circle.getRadius(); + LatLng center = circle.getCenter(); + double cX = center.latitude; + double cY = center.longitude; + double pX = point.latitude; + double pY = point.longitude; + + float[] results = new float[1]; + + Location.distanceBetween(cX, cY, pX, pY, results); + + if(results[0] < r) { + return true; + } else { + return false; + } } /** @@ -1078,9 +1073,9 @@ private boolean circleContainsPoint(Circle circle, LatLng point) { * @param point */ private boolean groundOverlayContainsPoint(GroundOverlay groundOverlay, LatLng point) { - LatLngBounds groundOverlayBounds = groundOverlay.getBounds(); - - return groundOverlayBounds.contains(point); + LatLngBounds groundOverlayBounds = groundOverlay.getBounds(); + + return groundOverlayBounds.contains(point); } @Override diff --git a/src/ios/GoogleMaps/GoogleMapsViewController.m b/src/ios/GoogleMaps/GoogleMapsViewController.m index 286c16b24..1852d0d6c 100644 --- a/src/ios/GoogleMaps/GoogleMapsViewController.m +++ b/src/ios/GoogleMaps/GoogleMapsViewController.m @@ -272,19 +272,19 @@ - (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker { } - (void)mapView:(GMSMapView *)mapView didTapOverlay:(GMSOverlay *)overlay { - NSString *overlayClass = NSStringFromClass([overlay class]); - if([overlayClass isEqualToString:@"GMSPolygon"]) { - [self triggerOverlayEvent:@"overlay_click" type:@"polygon" overlay:overlay]; - } - if([overlayClass isEqualToString:@"GMSPolyline"]) { - [self triggerOverlayEvent:@"overlay_click" type:@"polyline" overlay:overlay]; - } - if([overlayClass isEqualToString:@"GMSCircle"]) { - [self triggerOverlayEvent:@"overlay_click" type:@"circle" overlay:overlay]; - } - if([overlayClass isEqualToString:@"GMSGroundOverlay"]) { - [self triggerOverlayEvent:@"overlay_click" type:@"groundOverlay" overlay:overlay]; - } + NSString *overlayClass = NSStringFromClass([overlay class]); + if([overlayClass isEqualToString:@"GMSPolygon"]) { + [self triggerOverlayEvent:@"overlay_click" type:@"polygon" overlay:overlay]; + } + if([overlayClass isEqualToString:@"GMSPolyline"]) { + [self triggerOverlayEvent:@"overlay_click" type:@"polyline" overlay:overlay]; + } + if([overlayClass isEqualToString:@"GMSCircle"]) { + [self triggerOverlayEvent:@"overlay_click" type:@"circle" overlay:overlay]; + } + if([overlayClass isEqualToString:@"GMSGroundOverlay"]) { + [self triggerOverlayEvent:@"overlay_click" type:@"groundOverlay" overlay:overlay]; + } } /** @@ -334,9 +334,9 @@ - (void)triggerMarkerEvent: (NSString *)eventName marker:(GMSMarker *)marker */ - (void)triggerOverlayEvent: (NSString *)eventName type:(NSString *) type overlay:(GMSOverlay *)overlay { - NSString* jsString = [NSString stringWithFormat:@"plugin.google.maps.Map._onOverlayEvent('%@', '%@_%lu');", - eventName, type, (unsigned long)overlay.hash]; - [self.webView stringByEvaluatingJavaScriptFromString:jsString]; + NSString* jsString = [NSString stringWithFormat:@"plugin.google.maps.Map._onOverlayEvent('%@', '%@_%lu');", + eventName, type, (unsigned long)overlay.hash]; + [self.webView stringByEvaluatingJavaScriptFromString:jsString]; } //future support: custom info window diff --git a/src/ios/GoogleMaps/Polyline.m b/src/ios/GoogleMaps/Polyline.m index 9986e56f9..a9623e12f 100644 --- a/src/ios/GoogleMaps/Polyline.m +++ b/src/ios/GoogleMaps/Polyline.m @@ -44,7 +44,7 @@ -(void)createPolyline:(CDVInvokedUrlCommand *)command polyline.zIndex = [[json valueForKey:@"zIndex"] floatValue]; polyline.tappable = YES; - + NSString *id = [NSString stringWithFormat:@"polyline_%lu", (unsigned long)polyline.hash]; [self.mapCtrl.overlayManager setObject:polyline forKey: id];