{"id":931,"date":"2012-10-08T09:21:12","date_gmt":"2012-10-08T15:21:12","guid":{"rendered":"http:\/\/www.mooreds.com\/wordpress\/?p=931"},"modified":"2012-09-30T10:09:47","modified_gmt":"2012-09-30T16:09:47","slug":"towards-a-native-maps-plugin-for-phonegapcordova-and-android","status":"publish","type":"post","link":"https:\/\/www.mooreds.com\/wordpress\/archives\/931","title":{"rendered":"Towards a native maps plugin for PhoneGap\/Cordova and Android"},"content":{"rendered":"<p>I recently did some prototyping for a native maps plugin for Android. \u00a0For iOS\/phonegap, you have the <a href=\"https:\/\/github.com\/phonegap\/phonegap-plugins\/tree\/master\/iOS\/MapKit\">mapkit plugin<\/a>\u00a0which I was able to get working on phonegap 2.0, with <a href=\"https:\/\/groups.google.com\/forum\/?fromgroups=#!searchin\/phonegap\/mapkit\/phonegap\/HvpkQtUjXkY\/3nL22qnk9NYJ\">some help from the google group<\/a>. \u00a0But for Android, the concensus seems to be that you should use the web version of Google Maps (either the javascript version or the static map images). \u00a0While that advice works for a subset of users, if you pull out your Android phone and compare the performance between the web version of Google Maps and the native app, you&#8217;ll quickly choose the native app.<\/p>\n<p>There are two paths forward for a native map plugin. \u00a0The main limiting factor is that <a href=\"https:\/\/developers.google.com\/maps\/documentation\/android\/reference\/com\/google\/android\/maps\/MapView\">a native map view is only instantiable by a MapActivity<\/a>,&#8221;because it depends on threads which access the network and filesystem in the background; these threads must be shepherded by the lifecycle management&#8221; of the MapActivity.<\/p>\n<p>So, you can either:<\/p>\n<ul>\n<li>have your app be managed by a MapActivity and <a href=\"http:\/\/docs.phonegap.com\/en\/2.1.0\/guide_cordova-webview_android.md.html#Embedding%20Cordova%20WebView%20on%20Android\">embed a Cordova webview in the app<\/a>. \u00a0This would probably work well for apps that are really really map heavy, and only have a slight bit of webUI. \u00a0I&#8217;m not sure what value PhoneGap brings to that type of app, though. \u00a0It also seems pretty complex.<\/li>\n<li>or have the PhoneGap app transition from DroidGap activity to the MapActivity and then back.<\/li>\n<\/ul>\n<div>I went with the second choice. \u00a0As I said, this was an exploration, so there are plenty of problems that I skipped that will need to be solved to have a robust plugin:<\/div>\n<div>\n<ul>\n<li>which activity\/technology gets the points to display initially<\/li>\n<li>which activity\/technology gets points as the map is moved around<\/li>\n<li>testing on a real device (what do you do when you are running an Android device without native Google maps)<\/li>\n<li>passing full featured events back and forth between PhoneGap and the MapActivity<\/li>\n<\/ul>\n<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently did some prototyping for a native maps plugin for Android. \u00a0For iOS\/phonegap, you have the mapkit plugin\u00a0which I was able to get working on phonegap 2.0, with some [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[57,11,60],"tags":[],"class_list":["post-931","post","type-post","status-publish","format-standard","hentry","category-android","category-google-maps","category-phonegap"],"_links":{"self":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/931","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/comments?post=931"}],"version-history":[{"count":1,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/931\/revisions"}],"predecessor-version":[{"id":932,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/posts\/931\/revisions\/932"}],"wp:attachment":[{"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/media?parent=931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/categories?post=931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mooreds.com\/wordpress\/wp-json\/wp\/v2\/tags?post=931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}