Class MapSurface
A MapView provides an embeddable map interface.
You use this class to display map information and to manipulate the map contents from your application.
You can center the map on a given coordinate, specify the size of the area you want to display,
and style the features of the map to fit your application's use case.
Use of MapView requires a TrimbleMaps API access token.
Obtain an access token on the TrimbleMaps account page.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMapSurface(android.content.Context context, android.view.Surface surface) MapSurface(android.content.Context context, android.view.Surface surface, TrimbleMapsMapOptions options) -
Method Summary
Modifier and TypeMethodDescriptionvoidSet a callback that's invoked when the camera region did change.voidSet a callback that's invoked when the camera is changing.voidSet a callback that's invoked when the camera region will change.voidSet a callback that's invoked when map needs to release unused image resources.voidSet a callback that's invoked when the map has entered the idle state.voidSet a callback that's invoked when the map failed to load.voidSet a callback that's invoked when the map has finished loading.voidSet a callback that's invoked when the style has finished loading.voidSet a callback that's invoked when the map has finished rendering a frame.voidSet a callback that's invoked when the map has finished rendering.voidSet a callback that's invoked when a map source has changed.voidSet a callback that's invoked when the id of an icon is missing.voidSet a callback that's invoked when the map will start loading.voidSet a callback that's invoked when the map will start rendering a frame.voidSet a callback that's invoked when the map will start rendering.android.content.ContextfloatvoidgetMapAsync(OnMapReadyCallback callback) Sets a callback object which will be triggered when theTrimbleMapsMapinstance is ready to be used.floatReturns the map pixel ratio, by default it returns the device pixel ratio.floatgetWidth()protected voidinitialize(android.content.Context context, TrimbleMapsMapOptions options) booleanReturns if the map has been destroyed.voidonCreate(android.os.Bundle savedInstanceState) You must call this method from the parent's Activity#onCreate(Bundle)} or Fragment#onViewCreated(View, Bundle).voidYou must call this method from the parent's Activity#onDestroy() or Fragment#onDestroyView().voidYou must call this method from the parent's Activity#onLowMemory() or Fragment#onLowMemory().voidonPause()You must call this method from the parent's Activity#onPause() or Fragment#onPause().voidonResume()You must call this method from the parent's Activity#onResume() or Fragment#onResume().voidonSaveInstanceState(android.os.Bundle outState) You must call this method from the parent's Activity#onSaveInstanceState(Bundle) or Fragment#onSaveInstanceState(Bundle).voidonSizeChanged(int width, int height, int oldw, int oldh) voidonStart()You must call this method from the parent's Activity#onStart() or Fragment#onStart()voidonStop()You must call this method from the parent's Activity#onStop() or Fragment#onStop().voidqueueEvent(Runnable runnable) Queue a runnable to be executed on the map renderer thread.voidSet a callback that's invoked when the camera region did change.voidRemove a callback that's invoked when the camera is changing.voidRemove a callback that's invoked when the camera region will change.voidRemoves a callback that's invoked when map needs to release unused image resources.voidRemove a callback that's invoked when the map has entered the idle state.voidSet a callback that's invoked when the map failed to load.voidSet a callback that's invoked when the map has finished loading.voidSet a callback that's invoked when the style has finished loading.voidSet a callback that's invoked when the map has finished rendering a frame.voidRemove a callback that's invoked when the map has finished rendering.voidSet a callback that's invoked when a map source has changed.voidSet a callback that's invoked when a map source has changed.voidSet a callback that's invoked when the map will start loading.voidSet a callback that's invoked when the map will start rendering a frame.voidSet a callback that's invoked when the map will start rendering.static voidsetMapStrictModeEnabled(boolean strictModeEnabled) Sets the strict mode that will throw theMapStrictModeExceptionwhenever the map would fail silently otherwise.voidsetMaximumFps(int maximumFps) The maximum frame rate at which the map view is rendered, but it can't excess the ability of device hardware.
-
Field Details
-
glSurfaceView
-
-
Constructor Details
-
MapSurface
@UiThread public MapSurface(@NonNull android.content.Context context, android.view.Surface surface) -
MapSurface
@UiThread public MapSurface(@NonNull android.content.Context context, android.view.Surface surface, TrimbleMapsMapOptions options)
-
-
Method Details
-
initialize
@CallSuper @UiThread protected void initialize(@NonNull android.content.Context context, @NonNull TrimbleMapsMapOptions options) -
getContext
public android.content.Context getContext() -
onCreate
@UiThread public void onCreate(@Nullable android.os.Bundle savedInstanceState) You must call this method from the parent's Activity#onCreate(Bundle)} or Fragment#onViewCreated(View, Bundle).
You must set a valid access token withTrimbleMaps.getInstance(Context, com.trimblemaps.account.models.TrimbleMapsAccount, com.trimblemaps.mapsdk.WellKnownTileServer)before you call this method or an exception will be thrown.- Parameters:
savedInstanceState- Pass in the parent's savedInstanceState.- See Also:
-
onSaveInstanceState
@UiThread public void onSaveInstanceState(@NonNull android.os.Bundle outState) You must call this method from the parent's Activity#onSaveInstanceState(Bundle) or Fragment#onSaveInstanceState(Bundle).- Parameters:
outState- Pass in the parent's outState.
-
onStart
@UiThread public void onStart()You must call this method from the parent's Activity#onStart() or Fragment#onStart() -
onResume
@UiThread public void onResume()You must call this method from the parent's Activity#onResume() or Fragment#onResume(). -
onPause
@UiThread public void onPause()You must call this method from the parent's Activity#onPause() or Fragment#onPause(). -
onStop
@UiThread public void onStop()You must call this method from the parent's Activity#onStop() or Fragment#onStop(). -
onDestroy
@UiThread public void onDestroy()You must call this method from the parent's Activity#onDestroy() or Fragment#onDestroyView(). -
queueEvent
Queue a runnable to be executed on the map renderer thread.- Parameters:
runnable- the runnable to queue
-
setMaximumFps
public void setMaximumFps(int maximumFps) The maximum frame rate at which the map view is rendered, but it can't excess the ability of device hardware.- Parameters:
maximumFps- Can be set to arbitrary integer values.
-
isDestroyed
@UiThread public boolean isDestroyed()Returns if the map has been destroyed.This method can be used to determine if the result of an asynchronous operation should be set.
- Returns:
- true, if the map has been destroyed
-
onLowMemory
@UiThread public void onLowMemory()You must call this method from the parent's Activity#onLowMemory() or Fragment#onLowMemory(). -
onSizeChanged
public void onSizeChanged(int width, int height, int oldw, int oldh) -
getWidth
public float getWidth() -
getHeight
public float getHeight() -
getPixelRatio
public float getPixelRatio()Returns the map pixel ratio, by default it returns the device pixel ratio. Can be overwritten usingTrimbleMapsMapOptions.pixelRatio(float).- Returns:
- the current map pixel ratio
-
addOnCameraWillChangeListener
Set a callback that's invoked when the camera region will change.- Parameters:
listener- The callback that's invoked when the camera region will change
-
removeOnCameraWillChangeListener
Remove a callback that's invoked when the camera region will change.- Parameters:
listener- The callback that's invoked when the camera region will change
-
addOnCameraIsChangingListener
Set a callback that's invoked when the camera is changing.- Parameters:
listener- The callback that's invoked when the camera is changing
-
removeOnCameraIsChangingListener
Remove a callback that's invoked when the camera is changing.- Parameters:
listener- The callback that's invoked when the camera is changing
-
addOnCameraDidChangeListener
Set a callback that's invoked when the camera region did change.- Parameters:
listener- The callback that's invoked when the camera region did change
-
removeOnCameraDidChangeListener
Set a callback that's invoked when the camera region did change.- Parameters:
listener- The callback that's invoked when the camera region did change
-
addOnWillStartLoadingMapListener
public void addOnWillStartLoadingMapListener(@NonNull MapView.OnWillStartLoadingMapListener listener) Set a callback that's invoked when the map will start loading.- Parameters:
listener- The callback that's invoked when the map will start loading
-
removeOnWillStartLoadingMapListener
public void removeOnWillStartLoadingMapListener(@NonNull MapView.OnWillStartLoadingMapListener listener) Set a callback that's invoked when the map will start loading.- Parameters:
listener- The callback that's invoked when the map will start loading
-
addOnDidFinishLoadingMapListener
public void addOnDidFinishLoadingMapListener(@NonNull MapView.OnDidFinishLoadingMapListener listener) Set a callback that's invoked when the map has finished loading.- Parameters:
listener- The callback that's invoked when the map has finished loading
-
removeOnDidFinishLoadingMapListener
public void removeOnDidFinishLoadingMapListener(@NonNull MapView.OnDidFinishLoadingMapListener listener) Set a callback that's invoked when the map has finished loading.- Parameters:
listener- The callback that's invoked when the map has finished loading
-
addOnDidFailLoadingMapListener
Set a callback that's invoked when the map failed to load.- Parameters:
listener- The callback that's invoked when the map failed to load
-
removeOnDidFailLoadingMapListener
public void removeOnDidFailLoadingMapListener(@NonNull MapView.OnDidFailLoadingMapListener listener) Set a callback that's invoked when the map failed to load.- Parameters:
listener- The callback that's invoked when the map failed to load
-
addOnWillStartRenderingFrameListener
public void addOnWillStartRenderingFrameListener(@NonNull MapView.OnWillStartRenderingFrameListener listener) Set a callback that's invoked when the map will start rendering a frame.- Parameters:
listener- The callback that's invoked when the camera will start rendering a frame
-
removeOnWillStartRenderingFrameListener
public void removeOnWillStartRenderingFrameListener(@NonNull MapView.OnWillStartRenderingFrameListener listener) Set a callback that's invoked when the map will start rendering a frame.- Parameters:
listener- The callback that's invoked when the camera will start rendering a frame
-
addOnDidFinishRenderingFrameListener
public void addOnDidFinishRenderingFrameListener(@NonNull MapView.OnDidFinishRenderingFrameListener listener) Set a callback that's invoked when the map has finished rendering a frame.- Parameters:
listener- The callback that's invoked when the map has finished rendering a frame
-
removeOnDidFinishRenderingFrameListener
public void removeOnDidFinishRenderingFrameListener(@NonNull MapView.OnDidFinishRenderingFrameListener listener) Set a callback that's invoked when the map has finished rendering a frame.- Parameters:
listener- The callback that's invoked when the map has finished rendering a frame
-
addOnWillStartRenderingMapListener
public void addOnWillStartRenderingMapListener(@NonNull MapView.OnWillStartRenderingMapListener listener) Set a callback that's invoked when the map will start rendering.- Parameters:
listener- The callback that's invoked when the map will start rendering
-
removeOnWillStartRenderingMapListener
public void removeOnWillStartRenderingMapListener(@NonNull MapView.OnWillStartRenderingMapListener listener) Set a callback that's invoked when the map will start rendering.- Parameters:
listener- The callback that's invoked when the map will start rendering
-
addOnDidFinishRenderingMapListener
public void addOnDidFinishRenderingMapListener(@NonNull MapView.OnDidFinishRenderingMapListener listener) Set a callback that's invoked when the map has finished rendering.- Parameters:
listener- The callback that's invoked when the map has finished rendering
-
removeOnDidFinishRenderingMapListener
Remove a callback that's invoked when the map has finished rendering.- Parameters:
listener- The callback that's invoked when the map has has finished rendering.
-
addOnDidBecomeIdleListener
Set a callback that's invoked when the map has entered the idle state.- Parameters:
listener- The callback that's invoked when the map has entered the idle state.
-
removeOnDidBecomeIdleListener
Remove a callback that's invoked when the map has entered the idle state.- Parameters:
listener- The callback that's invoked when the map has entered the idle state.
-
addOnDidFinishLoadingStyleListener
public void addOnDidFinishLoadingStyleListener(@NonNull MapView.OnDidFinishLoadingStyleListener listener) Set a callback that's invoked when the style has finished loading.- Parameters:
listener- The callback that's invoked when the style has finished loading
-
removeOnDidFinishLoadingStyleListener
public void removeOnDidFinishLoadingStyleListener(@NonNull MapView.OnDidFinishLoadingStyleListener listener) Set a callback that's invoked when the style has finished loading.- Parameters:
listener- The callback that's invoked when the style has finished loading
-
addOnSourceChangedListener
Set a callback that's invoked when a map source has changed.- Parameters:
listener- The callback that's invoked when the source has changed
-
removeOnSourceChangedListener
Set a callback that's invoked when a map source has changed.- Parameters:
listener- The callback that's invoked when the source has changed
-
addOnStyleImageMissingListener
Set a callback that's invoked when the id of an icon is missing.- Parameters:
listener- The callback that's invoked when the id of an icon is missing
-
removeOnStyleImageMissingListener
public void removeOnStyleImageMissingListener(@NonNull MapView.OnStyleImageMissingListener listener) Set a callback that's invoked when a map source has changed.- Parameters:
listener- The callback that's invoked when the source has changed
-
addOnCanRemoveUnusedStyleImageListener
public void addOnCanRemoveUnusedStyleImageListener(@NonNull MapView.OnCanRemoveUnusedStyleImageListener listener) Set a callback that's invoked when map needs to release unused image resources.A callback will be called only for unused images that were provided by the client via
MapView.OnStyleImageMissingListener.onStyleImageMissing(String)listener interface.By default, platform will remove unused images from the style. By adding listener, default behavior can be overridden and client can control whether to release unused resources.
- Parameters:
listener- The callback that's invoked when map needs to release unused image resources
-
removeOnCanRemoveUnusedStyleImageListener
public void removeOnCanRemoveUnusedStyleImageListener(@NonNull MapView.OnCanRemoveUnusedStyleImageListener listener) Removes a callback that's invoked when map needs to release unused image resources.When all listeners are removed, platform will fallback to default behavior, which is to remove unused images from the style.
- Parameters:
listener- The callback that's invoked when map needs to release unused image resources
-
getMapAsync
Sets a callback object which will be triggered when theTrimbleMapsMapinstance is ready to be used.- Parameters:
callback- The callback object that will be triggered when the map is ready to be used.
-
setMapStrictModeEnabled
public static void setMapStrictModeEnabled(boolean strictModeEnabled) Sets the strict mode that will throw theMapStrictModeExceptionwhenever the map would fail silently otherwise.- Parameters:
strictModeEnabled- true to enable the strict mode, false otherwise
-