So it sounds like the current version of the Native Maps will be shut down pretty soon. I was wondering if anyone here has tried the V2 beta. Based on the documentation, it seems to be far superior. However the beta is just Cordova right now. I was wondering how easy it would be to implement it into Ionic 2. Then again, is it even worth the trouble? Anyone have any experience with the Beta?
Source for reference: GitHub - mapsplugin/cordova-plugin-googlemaps: Google Maps plugin for Cordova[quote=“stmc225, post:1, topic:81469”]
I was wondering how easy it would be to implement it into Ionic 2.
Current native code seems to be here: https://github.com/driftyco/ionic-native/blob/master/src/plugins/googlemap.ts
If v1 is not updated any more, probably yes. Google Maps integration can - and should - always be better.
Here is some more information on v2 + Ionic 2:
Thank you so much! Just one question, where exactly do I put the file for the current native code? And then how do I call it as an import for my own code?
Oh, I thought you already knew about Ionic Native. Sorry.
You don’t put the code anywhere but use Ionic native:
This way it is all in one style of coding that is supported and suggested by the Ionic team.
First off, I just want to say that you are continually the most helpful person on this forum. I would be completely lost without your help hahaha. I just have one more question regarding this. I think I initially misunderstood what this code here was. Now I understand why that, and the rest of the native code shouldn’t be changed. However, I still don’t know how to implement the code for the V2 Beta (there is a section for Ionic2 users, however, it isn’t exactly informative…). Do I just replace the current
cordova-plugin-googlemaps with the one from the V2 Beta? What exactly do I need to change?
Kinda missed to explain:
There is no real way to use v2 of the maps plugin in Ionic 2 yet. The way to use the v1 of the plugin is to use the Ionic Native “bindings” that are available right now. If you must use v2 beta, you could change the code of the bindings to match the new API of v2, using the code on Github I linked to. But this is probably a lot of work.
I assume Ionic will update Ionic Native to use v2 when it becomes available. They will also probably keep the old API of the Ionic native bindings alive, I assume, so you will be able to make the jump more easily.
Good news! I think I was able to get it to work. I just created a bank Ionic project, added the NATIVE maps plugin. Then I downloaded the V2 Beta Demo. I then deleted the
cordova-plugin-googlemaps from the ionic project and replaced it with the one from the V2 Demo. Seems to be working great so far. I think what’s going on here is that the Native plugin that is built into ionic is just calling source code from
cordova-plugin-googlemaps, so changing that file changes the way the Native works.
Yes, that’s exactly how it works. BUT v2 of the plugin changes parts of the API (function and event names) it offers to use, also some part is just not ready yet, see here for the exact changes: https://github.com/mapsplugin/cordova-plugin-googlemaps/wiki/Migrate-from-v1-to-v2 If the Ionic Native wrapper uses one of these, it will not work as expected with v2.
cordova-plugin-googlemaps worked on my brand new blank Ionic project, however, it didn’t work on the main project I’ve been working on. It is still functioning like v1.4. Any idea as to why? If now, I’ll just copy and paste everything into the working project
Do you know how to add an eventListener to a marker by any chance in V2?
Nope sorry, no idea.
It’s alright, thanks anyways. I’ve pretty much given up on the core map functionality because I’ve really began to realize that using a map is a very inefficient way to display larges amount of data.