HERE Android SDK Developer's Guide

CompositeFragment

The class CompositeFragment is a member of com.here.android.mpa.ar .

Class Summary

public class CompositeFragment

extends java.lang.Object

Composite fragment which enables usage of AR and Map functionality within the same view context.

[For complete information, see the section Class Details]

See also:

MapFragment

Constructor Summary

Table 1. Constructors in CompositeFragment
Constructors

CompositeFragment ()

Constructor

Method Summary

Table 2. Methods in CompositeFragment
Methods

public void addOnMapRenderListener (OnMapRenderListener listener)

Adds a OnMapRenderListener to listen for map render events.

public ARController getARController ()

Get ARController

public ViewRect getClipRect ()

Returns the ViewRect representing the clip rectangle for this CompositeFragment.

public Rect getCopyrightBoundaryRect ()

Gets the current HERE copyright logo's boundary rectangle.

public int getCopyrightLogoHeight ()

Returns the height of the copyright logo.

public CopyrightLogoPosition getCopyrightLogoPosition ()

Returns the on-screen position of the HERE copyright logo as a CopyrightLogoPosition value.

public int getCopyrightLogoWidth ()

Returns the width of the copyright logo.

public int getCopyrightMargin ()

Returns the current margin for the HERE copyright logo, in number of pixels, as an offset from the edge of the visible map area to the edge of the logo.

public int getHeight ()

Gets the current height of the fragment, in pixels.

public Map getMap ()

Returns the instance of Map associated with this fragment

public MapGesture getMapGesture ()

Returns the MapGesture object representing the current gesture handler for the CompositeFragment.

public void getScreenCapture (OnScreenCaptureListener listener)

Returns the full screen bitmap for the CompositeFragment.

public int getWidth ()

Gets the current width of the fragment, in pixels.

public void init (OnEngineInitListener listener)

Users of CompositeFragment must call this function after the fragment is first attached to its activity.

public void init (Context context, OnEngineInitListener listener)

Deprecated: As of SDK 3.4.

User of CompositeFragment must call this function after the fragment is created.

public void init (Context context, MapVariant variant, OnEngineInitListener listener)

Deprecated: As of SDK 3.4.

User of CompositeFragment must call this function after the fragment is created.

public void init (ApplicationContext context, OnEngineInitListener listener)

Users of CompositeFragment must call this function after the fragment is first attached to its activity.

public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

For documentation, see android.app.Fragment.onCreateView(LayoutInflater, viewGrup, Bundle)

public void onDestroyView ()

For documentation, see android.app.Fragment.onDestroyView()

public void onInflate (Activity activity, AttributeSet attrs, Bundle savedInstanceState)

For documentation, see android.app.Fragment.onInflate(Activity, AttributeSet, Bundle)

public void onPause ()

Called when this fragment is no longer resumed.

public void onResume ()

Called when this fragment is visible to the user and actively running.

public void onSaveInstanceState (Bundle outState)

public void removeOnMapRenderListener (OnMapRenderListener listener)

Removes an existing OnMapRenderListener.

public void setClipRect (ViewRect rect, PointF transformCenter)

Sets a clipping rectangle to the CompositeFragment.

public void setClipRect (ViewRect rect)

Sets a clipping rectangle to this CompositeFragment.

public void setCopyrightBoundaryRect (Rect rect)

Sets a rectangle, in pixels, relative to the top left corner of the CompositeFragment 's boundary, for the placement of the HERE copyright logo.

public void setCopyrightLogoPosition (CopyrightLogoPosition position)

Sets a position for the HERE copyright logo.

public void setCopyrightMargin (int margin)

Sets a margin for the HERE copyright logo, in number of pixels, as an offset from the edge of the visible map area to the edge of the logo (depending on the placement).

public void setMapMarkerDragListener (OnDragListener listener)

Sets a OnDragListener to be invoked whenever any MapMarker on a Map that is attached to this fragment is dragged.

public void setOnTouchListener (View.OnTouchListener listener)

Sets an android.view.OnTouchListener to be invoked whenever a touch event is sent to the CompositeFragment.

Class Details

Composite fragment which enables usage of AR and Map functionality within the same view context. This class contains methods which are specific to Map as well as methods specific to AR. Concretely, provides the same functionality as MapFragment in addition to AR functionality.

See also:

MapFragment

Constructor Details

CompositeFragment ()

Constructor

Method Details

public void addOnMapRenderListener (OnMapRenderListener listener)

Adds a OnMapRenderListener to listen for map render events.

Parameters:

  • listener

    A OnMapRenderListener to add to the CompositeFragment

See also:

removeOnMapRenderListener(OnMapRenderListener)

public ARController getARController ()

Get ARController

Returns:

ARController object

public ViewRect getClipRect ()

Returns the ViewRect representing the clip rectangle for this CompositeFragment.

Returns:

The clip rectangle for rendering MapObjects and similar map-related screen elements. null if the view's layout process has yet to be completed. If the process is not yet complete, users can either retry later or subscribe as a OnMapRenderListener and call this method upon the callback OnMapRenderListener.onSizeChanged(int,int).

public Rect getCopyrightBoundaryRect ()

Gets the current HERE copyright logo's boundary rectangle. Returns null if a boundary rect has not been set previously.

Returns:

The copyright logo's boundary rect. null if a boundary rect has not been set previously.

See also:

setCopyrightBoundaryRect(Rect)

public int getCopyrightLogoHeight ()

Returns the height of the copyright logo.

This method only returns a valid value once fragment initialization has taken completed.

Returns:

The height of the copyright logo, in number of pixels

public CopyrightLogoPosition getCopyrightLogoPosition ()

Returns the on-screen position of the HERE copyright logo as a CopyrightLogoPosition value.

Returns:

The position of the logo.

public int getCopyrightLogoWidth ()

Returns the width of the copyright logo.

This method only returns a valid value once fragment initialization has completed.

Returns:

The width of the copyright logo, in number of pixels

public int getCopyrightMargin ()

Returns the current margin for the HERE copyright logo, in number of pixels, as an offset from the edge of the visible map area to the edge of the logo.

This method only returns a valid value once fragment initialization has taken place.

Returns:

The current offset from the edge of the CompositeFragment, in number of pixels

public int getHeight ()

Gets the current height of the fragment, in pixels.

Returns:

The current height

public Map getMap ()

Returns the instance of Map associated with this fragment

Returns:

The Map object currently displayed in this fragment.

public MapGesture getMapGesture ()

Returns the MapGesture object representing the current gesture handler for the CompositeFragment. Applications can intercept this object and override the default event behaviors.

Returns:

The MapGesture

public void getScreenCapture (OnScreenCaptureListener listener)

Returns the full screen bitmap for the CompositeFragment. This method is asynchronous and will invoke a callback once the operation is completed through the operation is completed through the OnScreenCaptureListener the CompositeFragment must be visible to create the screen capture. Note that the current functionality of this API is limited to getting a screen capture of the Map. Future releases maybe enhanced to support getting screen capture of the AR and Map composite.

Parameters:

  • listener

    A OnScreenCaptureListener to listen for the callback when screen capture is complete.

public int getWidth ()

Gets the current width of the fragment, in pixels.

Returns:

The current width

public void init (OnEngineInitListener listener)

Users of CompositeFragment must call this function after the fragment is first attached to its activity. This automatically initializes the MapEngine and creates an ARController for use. This method is a convenience method that can be used for fragments embedded in a layout XML. This method should not be used when programmatically creating an CompositeFragment .

This method will initialize MapEngine with GLOBAL map variant on first SDK usage and with stored map variant on sub-sequent usages.

Parameters:

  • listener

    A OnEngineInitListener object that will be called when CompositeFragment and MapEngine initialization is finished. A null object can be supplied if callers do not expect any notification when initialization completes.

See also:

OnEngineInitListener

init(ApplicationContext, OnEngineInitListener)

init(Context, OnEngineInitListener)

public void init (Context context, OnEngineInitListener listener)

Deprecated: As of SDK 3.4.

Use init(ApplicationContext, OnEngineInitListener) instead.

User of CompositeFragment must call this function after the fragment is created. This automatically initialises the MapEngine and creates an ARController for use. This method can be used when programmatically creating an CompositeFragment .

This method will initialize MapEngine with GLOBAL map variant on first SDK usage and with stored map variant on sub-sequent usages.

Parameters:

  • context
  • listener

    A OnEngineInitListener object that will be called when CompositeFragment and MapEngine initialization is finished. A null object can be supplied if callers do not expect any notification when initialization completes.

See also:

OnEngineInitListener

init(Context, OnEngineInitListener)

init(OnEngineInitListener)

public void init (Context context, MapVariant variant, OnEngineInitListener listener)

Deprecated: As of SDK 3.4.

Use init(ApplicationContext, OnEngineInitListener) instead.

User of CompositeFragment must call this function after the fragment is created. This automatically initialises the MapEngine and creates an ARController for use. This method can be used when programmatically creating an CompositeFragment .

This method can configure map variant which will be used by MapEngine. If initialization fails - OPERATION_NOT_ALLOWED will be reported. Currently following variants are supported: - GLOBAL - initialize MapEngine to use international map variant; - KOREA - initialize MapEngine to use Korean map variant; - null - initialize MapEngine to use stored map variant or international map variant for first run. This method is used to configure MapEngine to use certain map variant. If MapEngine was already configured and passed variant differs - error will be reported and initialization fails.

Parameters:

  • context
  • variant

    Map variant to use.

  • listener

    A OnEngineInitListener object that will be called when CompositeFragment and MapEngine initialization is finished. A null object can be supplied if callers do not expect any notification when initialization completes.

See also:

OnEngineInitListener

init(Context, OnEngineInitListener)

init(OnEngineInitListener)

public void init (ApplicationContext context, OnEngineInitListener listener)

Users of CompositeFragment must call this function after the fragment is first attached to its activity. This automatically initializes the MapEngine and creates an ARController for use. This method is a convenience method that can be used for fragments embedded in a layout XML. This method should not be used when programmatically creating an CompositeFragment .

Parameters:

  • context

    ApplicationContext to be used during initialization.

  • listener

    A OnEngineInitListener object that will be called when CompositeFragment and MapEngine initialization is finished. A null object can be supplied if callers do not expect any notification when initialization completes.

See also:

OnEngineInitListener

init(ApplicationContext, OnEngineInitListener)

init(ApplicationContext, OnEngineInitListener)

public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

For documentation, see android.app.Fragment.onCreateView(LayoutInflater, viewGrup, Bundle)

Parameters:

  • inflater
  • container
  • savedInstanceState

public void onDestroyView ()

For documentation, see android.app.Fragment.onDestroyView()

public void onInflate (Activity activity, AttributeSet attrs, Bundle savedInstanceState)

For documentation, see android.app.Fragment.onInflate(Activity, AttributeSet, Bundle)

Parameters:

  • activity
  • attrs
  • savedInstanceState

public void onPause ()

Called when this fragment is no longer resumed. All MapEngine activities will be paused automatically.

See also:

android.app.Fragment#onPause()

public void onResume ()

Called when this fragment is visible to the user and actively running. All MapEngine activities will be resumed automatically.

See also:

android.app.Fragment#onResume()

public void onSaveInstanceState (Bundle outState)

Parameters:

  • outState

public void removeOnMapRenderListener (OnMapRenderListener listener)

Removes an existing OnMapRenderListener.

Parameters:

  • listener

    A OnMapRenderListener to remove from the CompositeFragment

public void setClipRect (ViewRect rect, PointF transformCenter)

Sets a clipping rectangle to the CompositeFragment. Only the area specified by the ViewRect will be used for rendering, while the rest of the view will be masked in black. This rectangle will be reset to the full size of the CompositeFragment upon screen rotation or upon recreating the screen.

Note that setting a clipping rectangle will also reset the CompositeFragment 's viewing rectangle to its full default size.

If the ViewRect is not valid, this method does nothing.

Parameters:

  • rect

    A ViewRect for rendering MapObjects and similar map-related screen elements

  • transformCenter

    A android.graphics.PointF representing the center coordinate for map transformations such as zooming and rotation

See also:

setClipRect(ViewRect)

public void setClipRect (ViewRect rect)

Sets a clipping rectangle to this CompositeFragment. Only the area specified by the ViewRect will be used for rendering, while the rest of the view will be masked in black. This rectangle will be reset to the full size of the CompositeFragment upon screen rotation or upon recreating the screen.

If the ViewRect is not valid, this method does nothing.

Parameters:

  • rect

    A ViewRect for rendering MapObjects and similar map-related screen elements

See also:

setClipRect(ViewRect, PointF)

public void setCopyrightBoundaryRect (Rect rect)

Sets a rectangle, in pixels, relative to the top left corner of the CompositeFragment 's boundary, for the placement of the HERE copyright logo.

If the specified rectangle is not contained completely within the current visible map area, their area of intersection will be used instead of the specified rectangle's area. The copyright logo and copyright margin must fit into the rectangle, otherwise specified rectangle will be ignored.

The rectangle is reset upon screen rotation or upon screen re-creation, or it can be done by setting a null - android.graphics.Rect .

Parameters:

  • rect

    A android.graphics.Rect representing the desired rectangular container to be used for positioning the copyright logo. Use null android.graphics.Rect to reset the boundary container.

public void setCopyrightLogoPosition (CopyrightLogoPosition position)

Sets a position for the HERE copyright logo. The current default is to place the logo at the center-bottom of the visible map view area.

After the logo's position is set, the position stays effective even when the screen is rotated or re-created.

Parameters:

  • position

    A CopyrightLogoPosition value representing the desired placement of the HERE copyright logo with respect to the visible map view area

public void setCopyrightMargin (int margin)

Sets a margin for the HERE copyright logo, in number of pixels, as an offset from the edge of the visible map area to the edge of the logo (depending on the placement).

Parameters:

public void setMapMarkerDragListener (OnDragListener listener)

Sets a OnDragListener to be invoked whenever any MapMarker on a Map that is attached to this fragment is dragged.

Parameters:

public void setOnTouchListener (View.OnTouchListener listener)

Sets an android.view.OnTouchListener to be invoked whenever a touch event is sent to the CompositeFragment.

Parameters:

See also:

android.view.View.OnTouchListener

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.