HERE Android SDK Developer's Guide

StreetLevelFragment

The class StreetLevelFragment is a member of com.here.android.mpa.streetlevel .

Class Summary

public class StreetLevelFragment

extends java.lang.Object

Represents a street level fragment.

[For complete information, see the section Class Details]

See also:

android.app.Fragment

Constructor Summary

Table 1. Constructors in StreetLevelFragment
Constructors

StreetLevelFragment ()

Constructor

Method Summary

Table 2. Methods in StreetLevelFragment
Methods

public Rect getCopyrightBoundaryRect ()

Gets the current HERE copyright logo's boundary rectangle.

public int getCopyrightLogoHeight ()

Returns the height of the copyright logo.

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 street level area to the edge of the logo.

public void getScreenCapture (OnScreenCaptureListener listener)

Gets the full screen bitmap for the android.view.View.

public StreetLevelGesture getStreetLevelGesture ()

Gets the StreetLevelGesture interface for the StreetLevelModel, used to enable or disable gestures.

public StreetLevelModel getStreetLevelModel ()

Retrieve the StreetLevelModel.

public void init (OnEngineInitListener listener)

User of StreetLevelFragment 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 StreetLevelFragment 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 StreetLevelFragment must call this function after the fragment is created.

public void init (ApplicationContext context, OnEngineInitListener listener)

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

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

Called when a fragment is first attached to its activity.

public void onDestroy ()

Called when the fragment is destroyed.

public void onDestroyView ()

Called when the view previously created by onCreateView(LayoutInflater, ViewGroup, Bundle) has been detached from the fragment.

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

Called when a fragment is being created as part of a view layout inflation, typically from setting the content view of an activity.

public void onPause ()

Called when the Fragment is no longer resumed.

public void onResume ()

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

public void onSaveInstanceState (Bundle outState)

Called when this fragment has been asked to save its current dynamic state.

public void setBlankStreetLevelImageVisible (boolean visible)

Request the view to draw "black" so a model can be reused without showing the previous street level image.This is useful in case an application tries to display the street level image for a location where street level coverage is not available.This API ensures that a "black" image is displayed if there is no street level coverage for the new location.

public void setCopyrightBoundaryRect (Rect rect)

Sets a rectangle, in pixels, relative to the top left corner of the StreetLevelFragment's boundary, for the placement of 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 street level area to the edge of the logo (depending on the placement).If the copyright logo position is BOTTOM_LEFT the vertical offset is from to the top of the copyright text.If copyright logo position is BOTTOM_RIGHT the vertical offset is from the top of the Report Image link.

public void setOnTouchListener (View.OnTouchListener listener)

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

Class Details

Represents a street level fragment. This is the fragment class designed to handle all UI-related use cases, including rendering and screen touch events.

Note: each StreetLevelFragment must be bound to a StreetLevelModel instance, and StreetLevel objects should be persisted during application runtime. StreetLevel objects live and expire according to the associated activity's lifecycle. This fragment has android.app.Fragment#setRetainInstance(boolean) set, and therefore the StreetLevelModel will retain any properties applied to it during an application's lifetime.

A StreetLevelFragment is defined in an Android layout XML file. For example:


 <fragment
   class="com.here.android.mpa.streetlevel.StreetLevelFragment"
   android:id="@+id/streetlevelfragment"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:layout_weight="1" />
  

Note: StreetLevelFragment automatically handles pause and resume of MapEngine during activity state changes, thus it is not necessary for the activity that owns StreetLevelFragment(s) to manually call onPause() / onResume() during the activity's onPause() and onResume(). However, considerations should be made regarding how much processing should be done in the onResume() method. Performing significant amounts of processing may delay the view rendering in cases such as device orientation change. It is recommended to use a specifically designated handler for organizing the amount of processing to be done in such cases.

See also:

android.app.Fragment

Constructor Details

StreetLevelFragment ()

Constructor

Method Details

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 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 street level area to the edge of the logo. If the copyright logo position is BOTTOM_LEFT the vertical offset is from to the top of the copyright text.If copyright logo position is BOTTOM_RIGHT the vertical offset is from the top of the Report Image link.The default copyright margin values is set to one-third of the logo width.

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

Returns:

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

public void getScreenCapture (OnScreenCaptureListener listener)

Gets the full screen bitmap for the android.view.View. This API can be used to capture a screen shot of the StreetLevelFragment The API is asynchronous and will callback once the operation is completed via OnScreenCaptureListener. Note the StreetLevelFragment must be visible to create the screen capture.

Parameters:

public StreetLevelGesture getStreetLevelGesture ()

Gets the StreetLevelGesture interface for the StreetLevelModel, used to enable or disable gestures.

Returns:

The StreetLevelGesture

public StreetLevelModel getStreetLevelModel ()

Retrieve the StreetLevelModel.

Returns:

the StreetLevelModel associated with this fragment

public void init (OnEngineInitListener listener)

User of StreetLevelFragment must call this function after the fragment is first attached to its activity. This automatically initialises the Restricted Map Factory and create a StreetLevelModel for use. This method is a method that should be used for fragments embedded in a layout XML. Do not use this method when StreetLevelFragment is created programatically.

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 will be called when StreetLevelFragment initialization is finished. A null object can be supplied if caller do not expect any notification when initialization completes.

See also:

OnEngineInitListener

init(ApplicationContext, OnEngineInitListener)

public void init (Context context, OnEngineInitListener listener)

Deprecated: As of SDK 3.4.

Use init(ApplicationContext, OnEngineInitListener) instead.

User of StreetLevelFragment must call this function after the fragment is created. This automatically initialises the Restricted Map Factory and create a StreetLevelModel for use. Do not use this method when StreetLevelFragment is created programatically.

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

Parameters:

  • context

    Context of the application.

  • listener

    A OnEngineInitListener object will be called when StreetLevelFragment initialization is finished. A null object can be supplied if caller do not expect any notification when initialization completes.

See also:

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 StreetLevelFragment must call this function after the fragment is created. This automatically initialises the Restricted Map Factory and create a StreetLevelModel for use. Do not use this method when StreetLevelFragment is created programatically.

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

    Context of the application.

  • variant

    Map variant to use.

  • listener

    A OnEngineInitListener object will be called when StreetLevelFragment initialization is finished. A null object can be supplied if caller do not expect any notification when initialization completes.

See also:

OnEngineInitListener

init(OnEngineInitListener)

public void init (ApplicationContext context, OnEngineInitListener listener)

User of StreetLevelFragment must call this function after the fragment is created. This automatically initialises the Restricted Map Factory and create a StreetLevelModel for use. Do not use this method when StreetLevelFragment is created programatically.

This method will initialize MapEngine with ApplicationContext to be used during initialization.

Parameters:

  • context

    ApplicationContext to be used during initialization.

  • listener

    A OnEngineInitListener object will be called when StreetLevelFragment initialization is finished. A null object can be supplied if caller do not expect any notification when initialization completes.

See also:

OnEngineInitListener

init(OnEngineInitListener)

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

Called when a fragment is first attached to its activity. A Street Level View is automatically setup to cover the full size of the StreetLevelFragment dimension.

Parameters:

  • inflater
  • container
  • savedInstanceState

See also:

android.app.Fragment#onAttach(android.app.Activity)

public void onDestroy ()

Called when the fragment is destroyed.

public void onDestroyView ()

Called when the view previously created by onCreateView(LayoutInflater, ViewGroup, Bundle) has been detached from the fragment. The StreetLevelModel created by the fragment will be detached from the fragment and destroyed automatically as part of the cleanup process. The android.view.android.view.View.OnTouchListener will also be disconnected from the fragment.

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

Called when a fragment is being created as part of a view layout inflation, typically from setting the content view of an activity. This may be called immediately after the fragment is created from a tag in a layout file.

Parameters:

  • activity
  • attrs
  • savedInstanceState

See also:

android.app.Fragment#onInflate(android.app.Activity, android.util.AttributeSet, android.os.Bundle)

public void onPause ()

Called when the Fragment is no longer resumed. All Map Engine activities will be paused automatically.

See also:

android.app.Fragment#onPause()

public void onResume ()

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

See also:

android.app.Fragment#onResume()

public void onSaveInstanceState (Bundle outState)

Called when this fragment has been asked to save its current dynamic state. Saving its current state allows for it to be later reconstructed in a new instance.

Parameters:

  • outState

See also:

android.app.Fragment#onSaveInstanceState(android.os.Bundle)

public void setBlankStreetLevelImageVisible (boolean visible)

Request the view to draw "black" so a model can be reused without showing the previous street level image.This is useful in case an application tries to display the street level image for a location where street level coverage is not available.This API ensures that a "black" image is displayed if there is no street level coverage for the new location.

Parameters:

  • visible

    Boolean value to indicate if the blank image represented by the "black" model is visible.

public void setCopyrightBoundaryRect (Rect rect)

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

If the specified rectangle is not contained completely within the current visible street level 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 - Rect .

Parameters:

  • rect

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

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 street level area to the edge of the logo (depending on the placement).If the copyright logo position is BOTTOM_LEFT the vertical offset is from to the top of the copyright text.If copyright logo position is BOTTOM_RIGHT the vertical offset is from the top of the Report Image link. The default copyright margin values is set to one-third of the logo width.

Parameters:

public void setOnTouchListener (View.OnTouchListener listener)

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

Parameters:

See also:

android.view.View.OnTouchListener