简体   繁体   中英

Using Amazon Maps beside Google Maps in the same app

As the title says I'm already using Google Maps in my app and I also would like to use Amazon Maps in case of Kindle devices. AM and GM v1 uses the same interface technically. How can i solve it nicely that depending on the device I'm using I get the appropriate class type (eg com.google.android.maps.MapView or com.amazon.geo.maps.MapView) for every class?

So let's say I need the appropriate version of the MapView class depending on my device because I want to construct a MapView object. As I said AM and GM has the same classes and methods but they don't implement a common interface though which prevents me from using a factory I think.

edit:

I hope I don't have to if(gmaps) { do something with gmaps objects } else if (amaps) { do the same with amaps objects }

As I said the problem I think is that the two API has the same classes, methods and everything but they don't actually implement a common interface which makes it hard for me do think up a nice solution. What do you think?

Thanks in advance!

You're looking for a design pattern named Proxy

But the Amazon Maps API looks like it mimics Google Maps v1, not the much better v2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM