bug fix: HtmlInfoWindow does not follow the marker if the htmlInfoWindow is opened by the open() method
MODIFY
src/android/plugin/google/maps/PluginMarker.java
src/android/plugin/google/maps/PluginMarker.java
@@ -502,6 +502,22 @@ public class PluginMarker extends MyPlugin implements MyPluginInterface {
}
}
+
+ public void setActiveMarkerId(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
+ final String id = args.getString(0);
+
+ cordova.getActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ Marker marker = (Marker) objects.get(id);
+ if (marker == null) {
+ return;
+ }
+ pluginMap.activeMarker = marker;
+ }
+ });
+ }
+
/**
*
* http://android-er.blogspot.com/2013/01/implement-bouncing-marker-for-google.html

MODIFY
src/ios/GoogleMaps/PluginMarker.h
src/ios/GoogleMaps/PluginMarker.h
- (void)getPosition:(CDVInvokedUrlCommand*)command;
- (void)setSnippet:(CDVInvokedUrlCommand*)command;
- (void)setTitle:(CDVInvokedUrlCommand*)command;
+- (void)setActiveMarkerId:(CDVInvokedUrlCommand*)command;
- (void)setFlat:(CDVInvokedUrlCommand*)command;
- (void)setOpacity:(CDVInvokedUrlCommand*)command;
- (void)setDraggable:(CDVInvokedUrlCommand*)command;

MODIFY
src/ios/GoogleMaps/PluginMarker.m
src/ios/GoogleMaps/PluginMarker.m
}];
}
+- (void)setActiveMarkerId:(CDVInvokedUrlCommand*)command {
+
+ [[NSOperationQueue mainQueue] addOperationWithBlock:^{
+
+ NSString *markerId = [command.arguments objectAtIndex:0];
+ GMSMarker *marker = [self.objects objectForKey:markerId];
+ if (marker == nil) {
+ return ;
+ }
+ self.mapCtrl.map.selectedMarker = marker;
+ }];
+}
+
/**
* Remove the specified marker
* @params markerId

MODIFY
www/HtmlInfoWindow.js
www/HtmlInfoWindow.js
@@ -204,7 +204,7 @@ HTMLInfoWindow.prototype.open = function(marker) {
var self = this;
map.fromLatLngToPoint(marker.getPosition(), function(point) {
- map.set("infoPosition", {x: point[0], y: point[1]})
+ map.set("infoPosition", {x: point[0], y: point[1]});
map.bindTo("infoPosition", self);
marker.bindTo("infoWindowAnchor", self);

MODIFY
www/Map.js
www/Map.js
@@ -38,6 +38,10 @@ var Map = function(id) {
value: id,
writable: false
});
+
+ self.on("active_marker_id_changed", function() {
+ exec(null, null, self.id + "-marker", 'setActiveMarkerId', [self.get("active_marker_id")]);
+ });
};
utils.extend(Map, BaseClass);
@@ -577,22 +581,15 @@ Map.prototype.setDiv = function(div) {
*/
Map.prototype.getVisibleRegion = function(callback) {
var self = this;
- var cameraPosition = self.get("camera");
-
- var latLngBounds = new LatLngBounds(cameraPosition.northeast, cameraPosition.southwest);
+ var northeast = self.get("camera_northeast");
+ var southwest = self.get("camera_southwest");
+ var latLngBounds = new LatLngBounds(northeast, southwest);
if (typeof callback === "function") {
- console.log("[deprecated] getVisibleRegion() is changed. Please check out the https://goo.gl/yHstHQ");
callback.call(self, latLngBounds);
}
- return {
- "latLngBounds" : latLngBounds,
- "nearLeft": new LatLng(cameraPosition.nearLeft.lat, cameraPosition.nearLeft.lng),
- "nearRight": new LatLng(cameraPosition.nearRight.lat, cameraPosition.nearRight.lng),
- "farLeft": new LatLng(cameraPosition.farLeft.lat, cameraPosition.farLeft.lng),
- "farRight": new LatLng(cameraPosition.farRight.lat, cameraPosition.farRight.lng)
- }
+ return latLngBounds;
};
/**
@@ -1043,7 +1040,9 @@ Map.prototype.getCameraTilt = function() {
Map.prototype.getCameraBearing = function() {
return this.get("camera_bearing");
};
-Map.prototype._onCameraEvent = function(eventName, cameraPosition) {
+Map.prototype._onCameraEvent = function(eventName, params) {
+ //var cameraPosition = new CameraPosition(params);
+ var cameraPosition = params;
this.set('camera', cameraPosition);
this.set('camera_target', cameraPosition.target);
this.set('camera_zoom', cameraPosition.zoom);
@@ -1051,10 +1050,6 @@ Map.prototype._onCameraEvent = function(eventName, cameraPosition) {
this.set('camera_tilt', cameraPosition.viewAngle || cameraPosition.tilt);
this.set('camera_northeast', cameraPosition.northeast);
this.set('camera_southwest', cameraPosition.southwest);
- this.set('camera_nearLeft', cameraPosition.nearLeft);
- this.set('camera_nearRight', cameraPosition.nearRight);
- this.set('camera_farLeft', cameraPosition.farLeft);
- this.set('camera_farRight', cameraPosition.farRight);
this.trigger(eventName, cameraPosition, this);
};
module.exports = Map;

MODIFY
www/Marker.js
www/Marker.js
@@ -66,6 +66,13 @@ var Marker = function(map, id, markerOptions) {
}
});
+ if (markerOptions.infoWindow) {
+ console.log("[deprecated] the infoWindow option is deprecated. Please use event listener.");
+ self.on(event.MARKER_CLICK, function() {
+ self.trigger(event.INFO_OPEN);
+ });
+ }
+
self.on("position_changed", function(oldValue, position) {
exec(null, self.errorHandler, self.getPluginName(), 'setPosition', [self.getId(), position.lat, position.lng]);
@@ -95,7 +102,6 @@ var Marker = function(map, id, markerOptions) {
exec(null, self.errorHandler, self.getPluginName(), 'setIconAnchor', [self.getId(), anchor[0], anchor[1]]);
});
self.on("infoWindowAnchor_changed", function(oldValue, anchor) {
- console.log("infoWindowAnchor", anchor);
exec(null, self.errorHandler, self.getPluginName(), 'setInfoWindowAnchor', [self.getId(), anchor[0], anchor[1]]);
});
self.on("zIndex_changed", function(oldValue, zIndex) {

bug fix: HtmlInfoWindow does not follow the marker if the htmlInfoWindow is opened by the open() method