{"id":141,"date":"2023-01-30T18:09:20","date_gmt":"2023-01-30T16:09:20","guid":{"rendered":"https:\/\/www.contentecontent.com\/blog\/?p=141"},"modified":"2023-01-31T14:38:28","modified_gmt":"2023-01-31T12:38:28","slug":"cordova-google-maps-plugin-and-cordova-android-11","status":"publish","type":"post","link":"https:\/\/www.contentecontent.com\/blog\/2023\/01\/cordova-google-maps-plugin-and-cordova-android-11\/","title":{"rendered":"Cordova Google Maps Plugin and cordova-android 11"},"content":{"rendered":"<p>I&#8217;ve been using the <a href=\"https:\/\/github.com\/mapsplugin\/cordova-plugin-googlemaps\">Google Maps Plugin<\/a> for many years now in Cordova projects. It provides access to native Google maps, which imho gives a better user experience than using the JavaScript api. <!--more--><\/p>\n<p>Sadly the plugin doesn&#8217;t get updated anymore, even though I bought the developer a virtual beer a while ago. After having read <a href=\"https:\/\/github.com\/mapsplugin\/cordova-plugin-googlemaps\/issues\/2915\">this discussion<\/a> I first tried using the fork at <a href=\"https:\/\/github.com\/we-are-joinup\/cordova-plugin-googlemaps\">https:\/\/github.com\/we-are-joinup\/cordova-plugin-googlemaps\/<\/a> :<\/p>\n<ol>\n<li>Create the project and cd into the project directory<\/li>\n<li>run <code>cordova plugin add https:\/\/github.com\/we-are-joinup\/cordova-plugin-googlemaps\/<\/code><\/li>\n<li>run <code>cordova platform add android@11.0.0<\/code><\/li>\n<li>in platforms\/android\/cordova-plugin-googlemaps\/***-tbxml-android.gradle : in the <code>dependencies<\/code> {} replace <code>compile<\/code> by <code>implementation<\/code><\/li>\n<\/ol>\n<p>Building and running the app went fine, the map opened nicely, custom markers showed up after setting the right path. But <code>getMyLocation<\/code> would always fail, making this road a dead end. Back to the original plugin.<\/p>\n<p>Here&#8217;s how I got 2.7.1 going, with an additional plugin and some Java code patches:<\/p>\n<ol>\n<li>Create the project and cd into the project directory (or, when already present, remove the maps plugin and the Android platform)<\/li>\n<li>run <code>cordova plugin add cordova-plugin-androidx-adapter<\/code><\/li>\n<li>run <code>cordova plugin add cordova-plugin-google-maps<\/code><\/li>\n<li>Apply all patches mentioned <a href=\"https:\/\/github.com\/mapsplugin\/cordova-plugin-googlemaps\/pull\/2872\/commits\">here<\/a><\/li>\n<li>run <code>cordova platform add android@11.0.0<\/code><\/li>\n<\/ol>\n<p>Building and running the app went fine, and this time <code>getMyLocation<\/code> would actually work.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been using the Google Maps Plugin for many years now in Cordova projects. It provides access to native Google maps, which imho gives a better user experience than using the JavaScript api.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-cordova"],"_links":{"self":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts\/141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/comments?post=141"}],"version-history":[{"count":12,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":153,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/posts\/141\/revisions\/153"}],"wp:attachment":[{"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/media?parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/categories?post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.contentecontent.com\/blog\/wp-json\/wp\/v2\/tags?post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}