delete : MAP_LOADED event
add: POI_CLICK event
only passes the placeId, name, and latLng
add: MY_LOCATION_CLICK event
passes the mylocation(blue dot) location when you tap on it
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.2.0-beta-20180118-1456" 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.0-beta-20180118-1628" 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/android/plugin/google/maps/PluginMap.java
src/android/plugin/google/maps/PluginMap.java
@@ -13,6 +13,7 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
+import android.support.annotation.NonNull;
import android.util.Base64;
import android.util.Log;
import android.view.Gravity;
@@ -48,6 +49,7 @@ import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.MapStyleOptions;
import com.google.android.gms.maps.model.Marker;
+import com.google.android.gms.maps.model.PointOfInterest;
import com.google.android.gms.maps.model.Polygon;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.VisibleRegion;
@@ -77,7 +79,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
OnMyLocationButtonClickListener, OnIndoorStateChangeListener, InfoWindowAdapter,
GoogleMap.OnCameraIdleListener, GoogleMap.OnCameraMoveCanceledListener,
GoogleMap.OnCameraMoveListener, GoogleMap.OnCameraMoveStartedListener,
- GoogleMap.OnInfoWindowLongClickListener, GoogleMap.OnInfoWindowCloseListener {
+ GoogleMap.OnInfoWindowLongClickListener, GoogleMap.OnInfoWindowCloseListener, GoogleMap.OnMyLocationClickListener, GoogleMap.OnPoiClickListener {
private LatLngBounds initCameraBounds;
private Activity activity;
@@ -97,6 +99,7 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
public final ObjectCache objects = new ObjectCache();
+
private enum TEXT_STYLE_ALIGNMENTS {
left, center, right
}
@@ -295,6 +298,8 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
map.setOnInfoWindowClickListener(PluginMap.this);
map.setOnInfoWindowLongClickListener(PluginMap.this);
map.setOnInfoWindowCloseListener(PluginMap.this);
+ map.setOnMyLocationClickListener(PluginMap.this);
+ map.setOnPoiClickListener(PluginMap.this);
//Custom info window
map.setInfoWindowAdapter(PluginMap.this);
@@ -723,6 +728,8 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
map.setOnMyLocationButtonClickListener(null);
map.setOnMapLoadedCallback(null);
map.setOnMarkerDragListener(null);
+ map.setOnMyLocationClickListener(null);
+ map.setOnPoiClickListener(null);
} catch (SecurityException e) {
e.printStackTrace();
}
@@ -2421,6 +2428,16 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
return false;
}
+ @Override
+ public void onMyLocationClick(@NonNull Location location) {
+ PluginGeolocation.setLastLocation(location);
+ try {
+ JSONObject result = PluginUtil.location2Json(location);
+ jsCallback(String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s',{evtName: 'my_location_click', callback:'_onMapEvent', args: [%s]});}", mapId, result.toString(0)));
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
/**
* Notify the myLocationChange event to JS
@@ -2563,6 +2580,13 @@ public class PluginMap extends MyPlugin implements OnMarkerClickListener,
}
jsCallback(String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s', {evtName:'indoor_level_activated', callback:'_onMapEvent', args: [%s]});}", mapId, jsonStr));
}
+ @Override
+ public void onPoiClick(PointOfInterest pointOfInterest) {
+
+ String js = String.format(Locale.ENGLISH, "javascript:if(window.cordova){cordova.fireDocumentEvent('%s', {evtName: '%s', callback:'_onMapEvent', args:['%s', '%s', new plugin.google.maps.LatLng(%f, %f)]});}",
+ mapId, "poi_click", pointOfInterest.placeId, pointOfInterest.name, pointOfInterest.latLng.latitude, pointOfInterest.latLng.longitude);
+ jsCallback(js);
+ }
private void jsCallback(final String js) {
this.activity.runOnUiThread(new Runnable() {

MODIFY
src/ios/GoogleMaps/GoogleMapsViewController.m
src/ios/GoogleMaps/GoogleMapsViewController.m
[super didReceiveMemoryWarning];
}
+- (void)mapView:(GMSMapView *)mapView didTapPOIWithPlaceID:(NSString *)placeID name:(NSString *)name location:(CLLocationCoordinate2D)location {
+
+ NSString* jsString = [NSString
+ stringWithFormat:@"javascript:cordova.fireDocumentEvent('%@', {evtName: '%@', callback: '_onMapEvent', args: ['%@', '%@', new plugin.google.maps.LatLng(%f,%f)]});",
+ self.mapId, @"poi_click", placeID, name, location.latitude, location.longitude];
+ [self execJS:jsString];
+}
+
/**
* Called when the My Location button is tapped.
*
*/
- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate {
+ if (self.map.isMyLocationEnabled) {
+ // Since the google maps sdk for iOS does not provide any events when you tap on the blue dot,
+ // detect the user tap on it by myself
+ CGPoint blueDotPoint = [self.map.projection pointForCoordinate:self.map.myLocation.coordinate];
+ CGPoint tapPoint = [self.map.projection pointForCoordinate:coordinate];
+
+ if (ABS(blueDotPoint.x - tapPoint.x) < 10 && ABS(blueDotPoint.y - tapPoint.y) < 10) {
+
+ NSMutableDictionary *latLng = [NSMutableDictionary dictionary];
+ [latLng setObject:[NSNumber numberWithFloat:self.map.myLocation.coordinate.latitude] forKey:@"lat"];
+ [latLng setObject:[NSNumber numberWithFloat:self.map.myLocation.coordinate.longitude] forKey:@"lng"];
+
+ NSMutableDictionary *json = [NSMutableDictionary dictionary];
+
+ [json setObject:latLng forKey:@"latLng"];
+ [json setObject:[NSNumber numberWithFloat:[self.map.myLocation speed]] forKey:@"speed"];
+ [json setObject:[NSNumber numberWithFloat:[self.map.myLocation altitude]] forKey:@"altitude"];
+
+ //todo: calcurate the correct accuracy based on horizontalAccuracy and verticalAccuracy
+ [json setObject:[NSNumber numberWithFloat:[self.map.myLocation horizontalAccuracy]] forKey:@"accuracy"];
+ [json setObject:[NSNumber numberWithDouble:[self.map.myLocation.timestamp timeIntervalSince1970]] forKey:@"time"];
+ [json setObject:[NSNumber numberWithInteger:[self.map.myLocation hash]] forKey:@"hashCode"];
+
+ NSData* jsonData = [NSJSONSerialization dataWithJSONObject:json options:0 error:nil];
+ NSString* sourceArrayString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
+
+ NSString* jsString = [NSString
+ stringWithFormat:@"javascript:cordova.fireDocumentEvent('%@', {evtName: '%@', callback: '_onMapEvent', args: [%@]});",
+ self.mapId, @"my_location_click", sourceArrayString];
+ [self execJS:jsString];
+ }
+ }
+
if (self.activeMarker) {
/*
NSString *clusterId_markerId =[NSString stringWithFormat:@"%@", self.activeMarker.userData];
* Map tiles are loaded
*/
- (void) mapViewDidFinishTileRendering:(GMSMapView *)mapView {
- [self triggerMapEvent:@"map_loaded"];
+ // no longer available from v2.2.0
+ //[self triggerMapEvent:@"map_loaded"];
}
/**

MODIFY
www/event.js
www/event.js
module.exports = {
MAP_READY: 'map_ready',
- MAP_LOADED: 'map_loaded',
MAP_CLICK: 'map_click',
MAP_LONG_CLICK: 'map_long_click',
+ POI_CLICK: 'poi_click',
MY_LOCATION_BUTTON_CLICK: 'my_location_button_click',
+ MY_LOCATION_CLICK: 'my_location_click',
INDOOR_BUILDING_FOCUSED: 'indoor_building_focused',
INDOOR_LEVEL_ACTIVATED: 'indoor_level_activated',
CAMERA_MOVE_START: 'camera_move_start',

- delete : MAP_LOADED event

- add: POI_CLICK event (#1346)
only passes the placeId, name, and latLng

- add: MY_LOCATION_CLICK event
passes the mylocation(blue dot) location when you tap on it