Porting Google Maps v1 to HERE Maps

This porting guide introduces HERE reference library for Google Maps Android API v1, which provides a replacement library project and a set of wrapper APIs that allow Android developers to easily migrate their existing Google Maps v1 applications to use HERE Maps. Before you start porting, please make sure that you have fulfilled all the prerequisites described here.

This guide assumes that you have an existing Android application that uses the Google Maps Android API v1. To try the instructions presented in this porting guide on a sample, you can use, for example, the MapsDemo sample application that comes with API level 16 samples. The sample is located at <Android SDK installation path>/add-ons/addon-google_apis-google-16/samples and is present, if you installed the Google APIs and examples located under the Android 4.1.2 (API level 16) section in the Android SDK manager.

Step 1. Modifying the manifest file

You need to make some minor modifications to the AndroidManifest.xml file of your project to enable HERE Maps. First, specify the application version compatibility by adding or editing the following tag:

    <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="16" />

Add the additional permissions required by HERE:

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

Within the <application></application> block of tags, add the following library:

    <uses-library android:name="com.here.android" android:required="false" />

and modify the original v1 library line not to be required. Then correct maps are selected on runtime:

    <uses-library android:name="com.google.android.maps" android:required="false" />

All applications using HERE API must have a valid application ID (app ID) and application token (app token). See here how to obtain these. Once you have acquired the app ID and token, insert them within the <application></application> block of tags:

    <meta-data android:name="com.here.android.maps.appid" android:value="YOUR ID" />
    <meta-data android:name="com.here.android.maps.apptoken" android:value="YOUR TOKEN" />

Replace the YOUR ID and YOUR TOKEN strings with the appropriate credentials for your application.

HERE Maps require OpenGL and GPU, so make sure you have OpenGL ES 2.0 usage declared in the manifest file:

    <uses-feature android:glEsVersion="0x00020000" android:required="true" />

In addition, either the whole application or the activity using maps needs to have property android:hardwareAccelerated set true:

    <application ... android:hardwareAccelerated="true">

Example:

<manifest ... >

    <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="16" />
    
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />

    <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
    
    <application ... android:hardwareAccelerated="true">

        <uses-library android:name="com.here.android"/>
        <meta-data android:name="com.here.android.maps.appid" android:value="YOUR ID"/>
        <meta-data android:name="com.here.android.maps.apptoken" android:value="YOUR TOKEN"/>

        <activity >
            ...
        </activity>
   </application>
</manifest>

Step 2. Import and add the wrapper library

To begin, you must first import the HERE reference library for Google Maps Android API v1 and add it to the project which needs to have the wrapper included.

Follow these steps to add the library and to configure the project right:

  1. From Eclipse, right-click on your project and select Properties, then select Android tab.
  2. Under the Project Build Target section, select "Android 4.1.2".
  3. In the same Properties dialog, select Java Build Path from the left pane.
  4. Under Libraries tab, use the Add External Jars.. button to import com.google.android.maps.sdk.jar library into the project. The file can be found under <android-sdk-install-path>\sdk\extras\nokia\nokia_x_services\libs\here folder.
  5. Under the Order and Export tab, ensure that Android Private Libraries and the com.google.android.maps.sdk.jar library are selected (see figure 1). This ensures that they are packaged as part of your application.
  6. Click on the OK button to close the Properties dialog.
  7. From the Eclipse menu, click on Project. Initiate Clean and then build the project to ensure that your project is updated with the latest changes.
Figure 1. Android Private Libraries and the wrapper library exported.

Figure 1. Android Private Libraries and the wrapper library exported.

Step 3. Run and test your application

Your application will now use HERE Maps instead of Google Maps. There should be no need to make additional changes to the source code of your app. If you still have problems with the application after following the previous steps, make sure that:

  • If you are running the app in the emulator, the use of host GPU is enabled in the Android Virtual Device (AVD) settings and you have a SD card defined.
  • Your internet connection is working and proxy is properly set if needed.
  • Your app ID and token are valid, i.e. they match the ones created for your application and there are no typos.

Video: Porting to HERE Maps (Google Maps v1)

The media player is loading...


Last updated 12 August 2014

Back to top

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×