If the icon of a marker is a base64 string of an image, the callback provided to addMarker is never executed, like this:
map.addMarker({
icon: 'data:image/png;base64,aVZ...',
}, outcome => {
console.log(outcome); // this code never executes
});
I traced down the problem to these lines of code, which is where an error occurs: Cannot read property 'width' of undefined. The problem is that markerOptions.icon.size will always be undefined if markerOptions.icon is a string. The solution would be to add an if statement that will not execute those lines of code if the icon is a string. This is what I did and it works for me:
Also notice that I added a similar if statement for infoWindowAnchor:
I'm submitting a ... (check one with "x")
OS: (check one with "x")
cordova information: (run
$> cordova plugin list
)If you use
@ionic-native/google-maps
, please tell the package.json (only@ionic-native/core
and@ionic-native/google-maps
are fine mostly)Current behavior:
If the
icon
of a marker is a base64 string of an image, the callback provided toaddMarker
is never executed, like this:I traced down the problem to these lines of code, which is where an error occurs:
Cannot read property 'width' of undefined
. The problem is thatmarkerOptions.icon.size
will always beundefined
ifmarkerOptions.icon
is a string. The solution would be to add an if statement that will not execute those lines of code if the icon is a string. This is what I did and it works for me:Also notice that I added a similar if statement for
infoWindowAnchor
:because that logic also relies on
markerOptions.icon.size
.Expected behavior:
Invoking
.addMarker()
with a base64 string as theicon
should not trigger an error, and the callback should be executed.Screen capture or video record:
Related code, data or error log (please format your code or data):
Support this plugin activity
I appreicate if you give me a beer :beer: from here