What is the best way to support both google map apis (v1 and v2)?

前端 未结 2 753
野的像风
野的像风 2020-12-29 16:08

What is the best way to support both android map apis in my application ?

Google released the android google map api v2 while the v1 is still around

相关标签:
2条回答
  • 2020-12-29 16:44

    That one could be achieved using if/else statements, including in the manifest file the declaration for both the apis.

    Well, you cannot have "if/else statements" in the manifest.

    There are basically three scenarios from my standpoint:

    1. The device does not have OpenGL ES 2.0 or higher
    2. The device does have OpenGL ES 2.0 or higher but does not presently have the Google Play Services (possibly because it does not have the Play Store)
    3. The device has OpenGL ES 2.0 or higher and has Google Play Services

    As you note in your comment on another answer, my Scenario #1 cannot co-exist with the other two, simply because you must have the <uses-feature> element calling for OpenGL ES 2.0. And, since the Play Store does not support multiple APK files based on OpenGL ES API level, you cannot support Scenario #1 and the other two scenarios at the same time for the same Play Store listing. You would have to have two completely separate apps in the Play Store: one that only uses Maps V1 that works on all Android devices and one that uses Maps V2 (falling back to something else, like Maps V1, for my Scenario #2) that works on OpenGL ES 2.0+ devices.

    Also, bear in mind that Maps V1 API keys are not going to be available after 3 March 2013. Doing Maps V1 development after that point gets increasingly risky, as you have no way of getting fresh API keys should something go wrong with your development environment.

    Basically, what this means is that developing apps dependent upon Google Maps sucks in new and interesting ways, compared to the way it sucked before. Even if you say that you will abandon Maps V1 outright, there are the devices that fall into my Scenario #2. Hopefully, there are not that many, though there definitely are some (such as an HTC EVO 3G sitting near me). There should be no such devices running Android 3.0 and higher -- I'm pretty sure that OpenGL ES 2.0 was a hard-and-fast requirement for Android 3.0, and the Play Store should be on all of those devices (and, hence, Google Play Services should be available for all of them).

    Frankly, the best answer for some developers will be to dump Google entirely with respect to maps and use OpenStreetMap or something else that has greater stability, if they want to support Android 1.x/2.x devices.

    0 讨论(0)
  • 2020-12-29 16:59

    The OpenGL 2.0 requirement is more from a support perspective. I've found Google Maps Android API v2 to be running well on an HTC Wildfire, for instance!

    Short answer to your question: don't do it. Pick one, stick to it.

    Medium answer: don't do it. Pick one, stick to it. If you really need some of the old features and cannot recreate them in new v2 API then that suggests you should stick with v1.

    If its just a few old 2.1 devices you worry about - don't worry, people really shouldn't be using 2.1 any more as its got security flaws, you're doing a public service by not supporting it (encouraging users to update their phones...which is a little sad from an environmentally-friendly perspective but the manufacturers and carriers already forced that problem so don't let it be yours!).

    If its just a few non-openGL 2.0 devices you worry about, then ommit the feature requirement, though at the risk of some crazy problems occurring down the track. Probably best to provide a clear warning that problems may occurr on non-openGL 2.0 devices.

    If you really, really must support both versions then just do it. Not many people would be crazy enough to do the same that you will find a 'best-practices' list eventuating. You'd probably want to use one of the v1 API MapFragment solutions though, as it happens I wrote one: https://github.com/coreform/android-tandemactivities

    0 讨论(0)
提交回复
热议问题