(Android / iOS) map.addMarker() returns the width and height of the icon
MODIFY
plugin.xml
plugin.xml
<?xml version='1.0' encoding='utf-8'?>
-<plugin id="cordova-plugin-googlemaps" version="2.1.2-beta-20171129-2305" 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.1.2-beta-20171130-2245" 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/PluginMarker.java
src/android/plugin/google/maps/PluginMarker.java
@@ -205,6 +205,24 @@ public class PluginMarker extends MyPlugin implements MyPluginInterface {
_create(markerId, opts, new ICreateMarkerCallback() {
@Override
public void onSuccess(Marker marker) {
+ String markerTag = marker.getTag() + "";
+ if (icons.containsKey(markerTag)) {
+ Bitmap icon = icons.get(markerTag);
+ try {
+ result.put("width", icon.getWidth() / density);
+ result.put("height", icon.getHeight() / density);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ try {
+ result.put("width", 62);
+ result.put("height", 110);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
callbackContext.success(result);
}

MODIFY
src/ios/GoogleMaps/PluginMarker.m
src/ios/GoogleMaps/PluginMarker.m
CDVCommandDelegateImpl *cmdDelegate = (CDVCommandDelegateImpl *)self.commandDelegate;
[self _create:markerId markerOptions:json callbackBlock:^(BOOL successed, id result) {
CDVPluginResult* pluginResult;
+
if (successed == NO) {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:result];
} else {
+ GMSMarker *marker = result;
+ NSString *iconCacheKey = [NSString stringWithFormat:@"marker_icon_%@", marker.userData];
+ UIImage *image = [[UIImageCache sharedInstance] getCachedImageForKey:iconCacheKey];
+ if (image != nil) {
+ [createResult setObject:[NSNumber numberWithInt: (int)image.size.width] forKey:@"width"];
+ [createResult setObject:[NSNumber numberWithInt: (int)image.size.height] forKey:@"height"];
+ } else {
+ [createResult setObject:[NSNumber numberWithInt: 62] forKey:@"width"];
+ [createResult setObject:[NSNumber numberWithInt: 110] forKey:@"height"];
+ }
+
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:createResult ];
}
[cmdDelegate sendPluginResult:pluginResult callbackId:command.callbackId];

MODIFY
www/HtmlInfoWindow.js
www/HtmlInfoWindow.js
@@ -333,7 +333,7 @@ var HTMLInfoWindow = function() {
self.set("offsetY", offsetY);
- frame.style.bottom = (iconSize.height - infoOffset.y)+ "px";
+ frame.style.bottom = (iconSize.height + (iconSize.height - infoOffset.y))+ "px";
frame.style.left = ((-contentsWidth) / 2 + infoOffset.x) + "px";

MODIFY
www/Map.js
www/Map.js
@@ -1452,6 +1452,22 @@ Map.prototype.addMarker = function(markerOptions, callback) {
var self = this;
markerOptions = common.markerOptionsFilter(markerOptions);
exec.call(this, function(result) {
+ markerOptions.icon = markerOptions.icon || {};
+ if (typeof markerOptions.icon === 'string') {
+ markerOptions.icon = {
+ url: markerOptions.icon,
+ size: {}
+ };
+ }
+ markerOptions.icon.size = markerOptions.icon.size || {};
+ markerOptions.icon.size.width = markerOptions.icon.size.width || result.width;
+ markerOptions.icon.size.height = markerOptions.icon.size.height || result.height;
+ markerOptions.icon.anchor = markerOptions.icon.anchor || [markerOptions.icon.size.width / 2, markerOptions.icon.size.height];
+
+ if (!markerOptions.infoWindowAnchor) {
+ markerOptions.infoWindowAnchor = [markerOptions.icon.size.width / 2, 0];
+ }
+
var marker = new Marker(self, result.id, markerOptions, "Marker", exec);
self.MARKERS[result.id] = marker;

(Android / iOS) map.addMarker() returns the width and height of the icon