Skip to content

Installation

Masashi Katsumata edited this page Mar 13, 2014 · 24 revisions

##Automatic Installation

cordova plugin add https://github.com/wf9a5m75/phonegap-googlemaps-plugin --variable API_KEY_FOR_ANDROID=xxx --variable API_KEY_FOR_IOS=xxx

##Tutorial

###1. Create a project

$> cordova create MyProjectDir com.example.myapp MyMap

###2. Add platforms

$> cd MyProjectDir/
$> cordova platform add android ios

###3. (Only for Android platform) Link the project with Google Play Services library

$> cd $(your_android_sdk_path)/extras/google/google_play_services/libproject/google-play-services_lib/
$> android update lib-project -p .

//Go back to your project directory
$> cd MyProjectDir/platforms/android
$> android update -p . -l (relative_path_to_google_play_services)/extras/google/google_play_services/libproject/google-play-services_lib/
$> cd ../../

###4. (Only for Android platform) Displaying the debug certificate fingerprint

  • Find the keytool.
  • OS X and Linux: ~/.android/
  • Windows Vista and Windows 7: C:\Users\your_user_name.android
    *Display the SHA-1 fingerprint
//OS X and Linux
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

//Windows Vista and Windows 7
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

###5a. Obtain the Google Maps API Key for Android

###5b. Obtain the Google Maps API Key for iOS

##6. Install this plugin

$> cordova plugin add https://github.com/wf9a5m75/phonegap-googlemaps-plugin --variable API_KEY_FOR_ANDROID=xxx --variable API_KEY_FOR_IOS=xxxx

###7. Change the www/index.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript">
    document.addEventListener("deviceready", function() {
      var button = document.getElementById("button");
      button.addEventListener("click", onBtnClicked, false);
    }, false);
    function onBtnClicked() {
      var map = plugin.google.maps.Map.getMap();
      map.addEventListener(plugin.google.maps.event.MAP_READY, onMapInit);
    }
    function onMapInit(map) {
      map.showDialog();
    }
    </script>
  </head>
  <body>
    <button id="button">Init a map</button>
  </body>
</html>

###8. Copy & build

// Copy the www/* into the platforms/(android | ios)/www
$> cordova prepare

$> cordova build

###9. Run the code on your device

//For Android
$> cordova run android

//For iOS
$> cordova run ios

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