Skip to content

Map.isAvailable()

Masashi Katsumata edited this page May 19, 2014 · 8 revisions

###Description The Map.isAvailable() is a static method. You can check the availability of Google Maps Android API version 2 on the device.

Some Android OS (such as Amazon Kindle, Android Emulator, etc) do not contain the Google Play Services Framework and the Google Maps libraries. Google Maps Android API version 2 uses these libraries. It means the OS do not have the library, Google Maps Android API do not work, thus this plugin do not work.

In case of iOS, this method is stub, because the Google Maps iOS SDK contains all files.

###code

document.addEventListener("deviceready", function() {
  // Check the availability of Google Maps Android API v2.
  // Return always true in iOS.
  plugin.google.maps.Map.isAvailable(function(isAvailable, message) {
    if (isAvailable) {
      var map = plugin.google.maps.Map.getMap();
      map.addEventListener(plugin.google.maps.event.MAP_READY, onMapInit);
    } else {
      alert(message);
    }
  });
});

function onMapInit(map) {
  map.showDialog();
}

Join the official community

New versions will be announced through the official community. Stay tune!

Do you have a question or feature request?

Feel free to ask me on the issues tracker.

Or on the official community is also welcome!


New version 2.0-beta2 is available.

The cordova-googlemaps-plugin v2.0 has more faster, more features.

https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/tree/master/v2.0.0/README.md

Clone this wiki locally