Phonegap Usage

Masashi Katsumata edited this page Apr 15, 2015 · 8 revisions

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!

Jump to...

Clone this wiki locally

PhoneGap local install

The phonegap-googlemaps-plugin, gives you the ability to work with Native maps in your application. The plugin automatically handles access to Google Maps mobile SDKs.

To install this plugin on PhoneGap, you need to prepare your API keys for both Google Maps Android API v2 and Google Maps iOS SDK. The below tutorial explains how to obtain the API keys, and how to install this plugin. Please follow each steps.

0. Requirements

Before getting started you need to set up your environment properly.

Set the environment path to the Android SDK Platform-tools* and **Android SDK Build-tools Install Apache Ant Set the JAVA_HOME to the environment path.

$> which ant

$> which android

$> which git

$> which unzip

$> echo $JAVA_HOME

$> phonegap -v

Also you should install the latest versions. the latest versions of Android SDK platform-tools and Android SDK build-tools

1. Create a project

$> phonegap create HelloMap HelloMap

2. Add platforms

In order to add Android and iOS platforms, you need to build at once.

$> cd HelloMap/
$> phonegap build android
$> phonegap build ios

3. (Only for Android) Displaying the debug certificate fingerprint

  • Find the keytool.
    • OS X and Linux: ~/.android/

*Display the SHA-1 fingerprint

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android


4a. Obtain the Google Maps API Key for Android

  • Go to Google APIs Console.
  • Register your project
  • Turn on Google Maps Android API v2
  • Go to API Access page.
  • Click [Create New Android Key] button
  • In the resulting dialog, enter the SHA-1 fingerprint, then a semicolon, then your application's package name.
  • Write down the API Key See [the official document: Get an Android certificate and the Google Maps API key]

4b. Obtain the Google Maps API Key for iOS


5. Install this plugin

Unlike Apache Cordova, the PhoneGap CLI does not accept the --variable parameter. In order to install the plugin, download the, then extract it.

You need to modify the plugin.xml file. Open the plugin.xml with your text editor.

Find and delete the two lines: <preference name="API_KEY_FOR_ANDROID" /> and <preference name="API_KEY_FOR_IOS" />

And find and replace $API_KEY_FOR_ANDROID and $API_KEY_FOR_IOS with your API keys.

Then save the plugin.xml.

After that, you can install the plugin.

$> phonegap local plugin add (path to the plugin)/phonegap-googlemaps-plugin-master/

6. Change the www/index.html

<!DOCTYPE html>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript">
    var map;
    document.addEventListener("deviceready", function() {
      var div = document.getElementById("map_canvas");

      // Initialize the map view
      map =;

      // Wait until the map is ready status.
      map.addEventListener(, onMapReady);
    }, false);

    function onMapReady() {
      var button = document.getElementById("button");
      button.addEventListener("click", onBtnClicked, false);

    function onBtnClicked() {
    <div style="width:100%;height:400px" id="map_canvas"></div>
    <button id="button">Full Screen</button>

7. Run on your device

$> phonegap run android
$> phonegap run ios


PhoneGap Build

Alternative service of PhoneGap Build

Monaca Mobile is similar service with PhoneGap Build, but they accepts the binary files.

Tutorial for Monaca Mobile is available.