cordova-plugin-googlemaps
cordova-plugin-googlemaps copied to clipboard
Fix #2871 - Resolve blank map when running compiled with latest cordova-android (which uses AGP 4.1.3)
Fix #2871
From AGP 4.1.+ assert keyword/statements are enabled by the compile through code rewrite.
Which is causing PluginMap to fail
The issue is caused by PluginMap being initialised 2 times. The 2nd time it is initialised, CordovaPlugin.privateInitialize has assert to prevent this.
This PR removes initialising the PluginMap in CordovaGoogleMaps.getMap, because when it is added to PluginManager it will be initialised then.
NOTE
Although the relevant code in PluginManager and CordovaPlugin has not been changed for many years.
The plugin's codebase works for older cordova-android versions because they use older AGP.
In these older versions, assert keyword/statement do nothing
@ebhsgit I installed from your fork and I no longer get custom map marker icons. It always uses the default red pin from Google maps. Can you please test on your end to see if you have a similar problem?
The problem was that I was using a relative path ('./www/img/myimg.png'). When I switched to the full path (${cordova.file.applicationDirectory}www/img/myimg.png) then it worked. Of course the relative path was working before I switched to this fork, so perhaps you could still check that too.
@CodeWithOz
Please note my fork is not intended for production usage.
That said, there shouldn't be any changes related to map markers in the fork.
If you find the issue. Feel free to suggest a PR
I also have the issue with blank map. Works when AGP 4.0.2 is used, but is broken with AGP 4.1.x and above.
@wf9a5m75 please merge and publish a new version asap!
Kinda strange, because i don't see any changes that would cause that, but i can confirm what @CodeWithOz said. My Markers that are set via url: './assets/...' doesn't work anymore with your PR 🤔
I have not tested this fix but if it works please try to merge it so that we can use official release of this plugin and do not have to hack the solution ourselves in code. Without fix we are stuck to [email protected] and can not use latest [email protected] which needs Android Gradle Plugin (AGP) version 4.2.2. Thank you!
There are no changes in this branch related to markers.
This pr is branched from master.
Maybe you guys are using a different branch? eg: multiple_maps, there are lots of other changes between master and multiple_maps
Could you try the 20210804 branch? I'm working on the next version recently, and don't touch v2.x these days. But it seems I've tried to improve something.
No i'm using your branch @ebhsgit 🤔 Before i was using Version 2.7.1.
@wf9a5m75 i think this should be fixed in a hotfix 2.7.2 as it blocks the migration to cordova-android@10
@wf9a5m75 i just tried to install from your branch. I got a lot of build errors, for example:
L.92: Cannot resolve symbol 'viewPlugins'
L.102: Inconvertible types; cannot cast 'org.apache.cordova.PluginEntry' to 'plugin.google.maps.PluginMarker'
L.410: Cannot resolve method 'getGoogleMap' in 'PluginMap'
in PluginMarker.java
and lots of Errors in CordovaGoogleMaps.java, which seems all be related to:
L.52: Cannot resolve symbol 'MyPluginLayout'
All in all 66 Errors

@CodeWithOz @EinfachHans
Not sure what the issue is with icons.
The changes are simple, and are definitely not related to markers.
@ebhsgit give it a try yourself 😃
I am not experiencing any issues with markers
Do you add at least one via ./assets/...?
Yup.
eg:
./assets/imgs/map/markers/start.png
Do you just set the icon: './assets/imgs/map/markers/start.png' or do you set more options like size and anchor?
icon: {
url: '....',
size: '.....'
}
Strange, Version 2.7.1 works fine, but when i install from this PR directly it doesn't
https://github.com/mapsplugin/cordova-plugin-googlemaps/pull/2872#issuecomment-893316041
I was able to build the plugin in ionic v5 project at least.
Did you rebuild with command ionic cordova clean then ionic cordova build android?
@wf9a5m75 I completely removed the platforms, plugins, www, node_modules folder and the package_lock.json and installed and build everything from zero
Okay i debugged a bit more, looks like this Marker Problem is cordova-android related: https://github.com/apache/cordova-android/issues/1316 - Thanks 😊
Sadly still white map :(
It really needs to be fixed soon, because the switch to Android 11 (API Level 30) will be required by Google from 1st Nov 2021. Can the current fix be used in production at least?
The fix https://github.com/mapsplugin/cordova-plugin-googlemaps/commit/1de03cdb14f0239c23ac88d59ea296fa185be56e seemes to solve the white map issue but unfortunately, the app crashes when loading custom markers.
Actually, this fix by @ebhsgit seems to work with a clean install (reinstall platform and plugins, and also remove package-lock.json) https://github.com/mapsplugin/cordova-plugin-googlemaps/commit/0b8ea76ad34fb2a202a9de1b9d0e051a82ad9443. With the merge commit https://github.com/mapsplugin/cordova-plugin-googlemaps/commit/1de03cdb14f0239c23ac88d59ea296fa185be56e I got some build errors as pointed out by @EinfachHans
@wf9a5m75 any timeline on when this will be merged. Many of us are waiting for the fix since switch to Android 11 (API Level 30) will be required by Google from 1st Nov 2021.
Could you please provide your thoughts upon this.
Thanks
@alexp25 comment out line 1150 and 1151 (result.image.recycle(),result.image = null) in the file src/android/plugin/google/maps/PluginMarker.java then custom markers work fine
@alexp25 @lrobak0 can someone please help me installing commit 1de03cd
Currently I am installing via below command cordova plugin add https://github.com/mapsplugin/cordova-plugin-googlemaps#1de03cdb14f0239c23ac88d59ea296fa185be56e
Is this correct?
I installed: https://github.com/mapsplugin/cordova-plugin-googlemaps#0b8ea76ad34fb2a202a9de1b9d0e051a82ad9443