Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Utilizing HERE Maps with components using v4 fragments

From Wiki
Jump to: navigation, search
Featured Article
30 Mar

This article explains how to use HERE Maps API with v4 fragments.

Article Metadata
Code Example
Source file: MapsInTabs
Created: symbianyucca (10 Mar 2014)
Last edited: croozeus (31 Mar 2014)



The HERE Maps API in general is designed to work with derived fragments, you could see this by checking the base classed with the API parts such as

If you want to use the, you cannot use the normal Map fragment in it. In this wiki article, I describe two alternatives with which you can use the HERE Maps API with APIs expecting you to use v4 fragments.

Parts for the solution were originally provided by an answer in Stack Overflow.

Using the Map View instead of Map Fragment

Instead of using the map through fragment, you can use the instead, and then use findViewById() to locate it from the layout. And then for the initialization, you would need to initialize the Factory, and then use the function from it for creating the map instance, which you can add into the view element.

MapFactory.initFactory(getActivity().getApplicationContext(), new FactoryInitListener() {
public void onFactoryInitializationCompleted(InitError error) {
if(error == InitError.NONE){
mMap = (Map) mMapView.getMap();
mMap.setCenter(MapFactory.createGeoCoordinate(48.8567, 2.3508), MapAnimation.NONE);

Using the Compatibility Fragment

There is also another possible way where you can use class instead of the By using this approach, you just need to simply change the API without changing the existing code.

Note that you can also use this API with API level 10 as mentioned in API docs.

Example code

Full example code which is utilising both method with Tabs can be found from GitHub: MapsInTabs

This page was last modified on 31 March 2014, at 11:46.
96 page views in the last 30 days.