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

前端 未结 2 752
野的像风
野的像风 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 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.

提交回复
热议问题