a

Wednesday, 12 August 2015

Geolocation and mapping



a.    Configure geolocation on Android, iOS, and Mobile Web
b.    Request geolocation permissions, accounting for platform-specific requirements
c.    Obtain the user’s current location and/or continually monitor the user’s location
d.    Perform forward and reverse geocoding
e.    Add a map to your app
f.     Set map options and properties
g.    Add annotations to your map, and set annotation options and properties
h.    Enable event handling for maps and annotations



Install the Google Play Services SDK

The Google Maps v2 module uses Google Maps Android API v2, which requires the Google Play Services SDK. To install the Google Play Services SDK, launch the Android SDK Manager and select to install Google Play services.
  1. To launch the Android SDK manager:
    #If the Android SDK tools folder is in your PATH:
    android
    #If not
    <path_to_android_sdk>/tools/android
  2. After the Android SDK Manager application launches, in the Extras folder, select Google Play services, then click Install X Packages....
  3. A dialog appears confirming your selection. Accept the license and click Install to continue.

Obtain and Add a Google API Key


  1. Create a Google API project and enable Google Map Android API v2 for the project
  2. Obtain and add a Google Maps API key to your project 
  3. For the SHA-1 certificate fingerprint, use JDK keytool command to extract the SHA-1 string from either the debug certificate. For Mac, use following
<ti:app>
    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            <application>
                <!-- Replace "PASTE YOUR GOOGLE MAPS API KEY HERE" with the Google API key you obtained -->
                <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="PASTE YOUR GOOGLE MAPS API KEY HERE"/>
            </application>
        </manifest>
    </android>
</ti:app>

Check for Google Play Services

var MapModule = require('ti.map');
var rc = MapModule.isGooglePlayServicesAvailable();
switch (rc) {
case MapModule.SUCCESS:
Ti.API.info('Google Play services is installed.');
break;
case MapModule.SERVICE_MISSING:
alert('Google Play services is missing. Please install Google Play services from the Google Play store.');
break;
case MapModule.SERVICE_VERSION_UPDATE_REQUIRED:
alert('Google Play services is out of date. Please update Google Play services.');
break;
case MapModule.SERVICE_DISABLED:
alert('Google Play services is disabled. Please enable Google Play services.');
break;
case MapModule.SERVICE_INVALID:
alert('Google Play services cannot be authenticated. Reinstall Google Play services.');
break;
default:
alert('Unknown error.');
}






No comments:

Post a Comment