public class MapSurface
extends java.lang.Object
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.
Modifier and Type | Field | Description |
---|---|---|
TrimbleMapsGLSurface |
glSurfaceView |
Constructor | Description |
---|---|
MapSurface(android.content.Context context,
android.view.Surface surface) |
|
MapSurface(android.content.Context context,
android.view.Surface surface,
TrimbleMapsMapOptions options) |
Modifier and Type | Method | Description |
---|---|---|
void |
addOnCameraDidChangeListener(MapView.OnCameraDidChangeListener listener) |
Set a callback that's invoked when the camera region did change.
|
void |
addOnCameraIsChangingListener(MapView.OnCameraIsChangingListener listener) |
Set a callback that's invoked when the camera is changing.
|
void |
addOnCameraWillChangeListener(MapView.OnCameraWillChangeListener listener) |
Set a callback that's invoked when the camera region will change.
|
void |
addOnCanRemoveUnusedStyleImageListener(MapView.OnCanRemoveUnusedStyleImageListener listener) |
Set a callback that's invoked when map needs to release unused image resources.
|
void |
addOnDidBecomeIdleListener(MapView.OnDidBecomeIdleListener listener) |
Set a callback that's invoked when the map has entered the idle state.
|
void |
addOnDidFailLoadingMapListener(MapView.OnDidFailLoadingMapListener listener) |
Set a callback that's invoked when the map failed to load.
|
void |
addOnDidFinishLoadingMapListener(MapView.OnDidFinishLoadingMapListener listener) |
Set a callback that's invoked when the map has finished loading.
|
void |
addOnDidFinishLoadingStyleListener(MapView.OnDidFinishLoadingStyleListener listener) |
Set a callback that's invoked when the style has finished loading.
|
void |
addOnDidFinishRenderingFrameListener(MapView.OnDidFinishRenderingFrameListener listener) |
Set a callback that's invoked when the map has finished rendering a frame.
|
void |
addOnDidFinishRenderingMapListener(MapView.OnDidFinishRenderingMapListener listener) |
Set a callback that's invoked when the map has finished rendering.
|
void |
addOnSourceChangedListener(MapView.OnSourceChangedListener listener) |
Set a callback that's invoked when a map source has changed.
|
void |
addOnStyleImageMissingListener(MapView.OnStyleImageMissingListener listener) |
Set a callback that's invoked when the id of an icon is missing.
|
void |
addOnWillStartLoadingMapListener(MapView.OnWillStartLoadingMapListener listener) |
Set a callback that's invoked when the map will start loading.
|
void |
addOnWillStartRenderingFrameListener(MapView.OnWillStartRenderingFrameListener listener) |
Set a callback that's invoked when the map will start rendering a frame.
|
void |
addOnWillStartRenderingMapListener(MapView.OnWillStartRenderingMapListener listener) |
Set a callback that's invoked when the map will start rendering.
|
android.content.Context |
getContext() |
|
float |
getHeight() |
|
void |
getMapAsync(OnMapReadyCallback callback) |
Sets a callback object which will be triggered when the
TrimbleMapsMap instance is ready to be used. |
float |
getPixelRatio() |
Returns the map pixel ratio, by default it returns the device pixel ratio.
|
float |
getWidth() |
|
protected void |
initialize(android.content.Context context,
TrimbleMapsMapOptions options) |
|
boolean |
isDestroyed() |
Returns if the map has been destroyed.
|
void |
onCreate(android.os.Bundle savedInstanceState) |
You must call this method from the parent's Activity#onCreate(Bundle)} or
Fragment#onViewCreated(View, Bundle).
|
void |
onDestroy() |
You must call this method from the parent's Activity#onDestroy() or Fragment#onDestroyView().
|
void |
onLowMemory() |
You must call this method from the parent's Activity#onLowMemory() or Fragment#onLowMemory().
|
void |
onPause() |
You must call this method from the parent's Activity#onPause() or Fragment#onPause().
|
void |
onResume() |
You must call this method from the parent's Activity#onResume() or Fragment#onResume().
|
void |
onSaveInstanceState(android.os.Bundle outState) |
You must call this method from the parent's Activity#onSaveInstanceState(Bundle)
or Fragment#onSaveInstanceState(Bundle).
|
void |
onSizeChanged(int width,
int height,
int oldw,
int oldh) |
|
void |
onStart() |
You must call this method from the parent's Activity#onStart() or Fragment#onStart()
|
void |
onStop() |
You must call this method from the parent's Activity#onStop() or Fragment#onStop().
|
void |
queueEvent(java.lang.Runnable runnable) |
Queue a runnable to be executed on the map renderer thread.
|
void |
removeOnCameraDidChangeListener(MapView.OnCameraDidChangeListener listener) |
Set a callback that's invoked when the camera region did change.
|
void |
removeOnCameraIsChangingListener(MapView.OnCameraIsChangingListener listener) |
Remove a callback that's invoked when the camera is changing.
|
void |
removeOnCameraWillChangeListener(MapView.OnCameraWillChangeListener listener) |
Remove a callback that's invoked when the camera region will change.
|
void |
removeOnCanRemoveUnusedStyleImageListener(MapView.OnCanRemoveUnusedStyleImageListener listener) |
Removes a callback that's invoked when map needs to release unused image resources.
|
void |
removeOnDidBecomeIdleListener(MapView.OnDidBecomeIdleListener listener) |
Remove a callback that's invoked when the map has entered the idle state.
|
void |
removeOnDidFailLoadingMapListener(MapView.OnDidFailLoadingMapListener listener) |
Set a callback that's invoked when the map failed to load.
|
void |
removeOnDidFinishLoadingMapListener(MapView.OnDidFinishLoadingMapListener listener) |
Set a callback that's invoked when the map has finished loading.
|
void |
removeOnDidFinishLoadingStyleListener(MapView.OnDidFinishLoadingStyleListener listener) |
Set a callback that's invoked when the style has finished loading.
|
void |
removeOnDidFinishRenderingFrameListener(MapView.OnDidFinishRenderingFrameListener listener) |
Set a callback that's invoked when the map has finished rendering a frame.
|
void |
removeOnDidFinishRenderingMapListener(MapView.OnDidFinishRenderingMapListener listener) |
Remove a callback that's invoked when the map has finished rendering.
|
void |
removeOnSourceChangedListener(MapView.OnSourceChangedListener listener) |
Set a callback that's invoked when a map source has changed.
|
void |
removeOnStyleImageMissingListener(MapView.OnStyleImageMissingListener listener) |
Set a callback that's invoked when a map source has changed.
|
void |
removeOnWillStartLoadingMapListener(MapView.OnWillStartLoadingMapListener listener) |
Set a callback that's invoked when the map will start loading.
|
void |
removeOnWillStartRenderingFrameListener(MapView.OnWillStartRenderingFrameListener listener) |
Set a callback that's invoked when the map will start rendering a frame.
|
void |
removeOnWillStartRenderingMapListener(MapView.OnWillStartRenderingMapListener listener) |
Set a callback that's invoked when the map will start rendering.
|
static void |
setMapStrictModeEnabled(boolean strictModeEnabled) |
Sets the strict mode that will throw the
MapStrictModeException
whenever the map would fail silently otherwise. |
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.
|
public TrimbleMapsGLSurface glSurfaceView
@UiThread public MapSurface(@NonNull android.content.Context context, android.view.Surface surface)
@UiThread public MapSurface(@NonNull android.content.Context context, android.view.Surface surface, TrimbleMapsMapOptions options)
@CallSuper @UiThread protected void initialize(@NonNull android.content.Context context, @NonNull TrimbleMapsMapOptions options)
public android.content.Context getContext()
@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, String)
before you call this method or an exception will be thrown.savedInstanceState
- Pass in the parent's savedInstanceState.TrimbleMaps#getInstance(Context, String)
@UiThread public void onSaveInstanceState(@NonNull android.os.Bundle outState)
outState
- Pass in the parent's outState.@UiThread public void onStart()
@UiThread public void onResume()
@UiThread public void onPause()
@UiThread public void onStop()
@UiThread public void onDestroy()
public void queueEvent(@NonNull java.lang.Runnable runnable)
runnable
- the runnable to queuepublic void setMaximumFps(int maximumFps)
maximumFps
- Can be set to arbitrary integer values.@UiThread public boolean isDestroyed()
This method can be used to determine if the result of an asynchronous operation should be set.
@UiThread public void onLowMemory()
public void onSizeChanged(int width, int height, int oldw, int oldh)
public float getWidth()
public float getHeight()
public float getPixelRatio()
TrimbleMapsMapOptions.pixelRatio(float)
.public void addOnCameraWillChangeListener(@NonNull MapView.OnCameraWillChangeListener listener)
listener
- The callback that's invoked when the camera region will changepublic void removeOnCameraWillChangeListener(@NonNull MapView.OnCameraWillChangeListener listener)
listener
- The callback that's invoked when the camera region will changepublic void addOnCameraIsChangingListener(@NonNull MapView.OnCameraIsChangingListener listener)
listener
- The callback that's invoked when the camera is changingpublic void removeOnCameraIsChangingListener(@NonNull MapView.OnCameraIsChangingListener listener)
listener
- The callback that's invoked when the camera is changingpublic void addOnCameraDidChangeListener(@NonNull MapView.OnCameraDidChangeListener listener)
listener
- The callback that's invoked when the camera region did changepublic void removeOnCameraDidChangeListener(@NonNull MapView.OnCameraDidChangeListener listener)
listener
- The callback that's invoked when the camera region did changepublic void addOnWillStartLoadingMapListener(@NonNull MapView.OnWillStartLoadingMapListener listener)
listener
- The callback that's invoked when the map will start loadingpublic void removeOnWillStartLoadingMapListener(@NonNull MapView.OnWillStartLoadingMapListener listener)
listener
- The callback that's invoked when the map will start loadingpublic void addOnDidFinishLoadingMapListener(@NonNull MapView.OnDidFinishLoadingMapListener listener)
listener
- The callback that's invoked when the map has finished loadingpublic void removeOnDidFinishLoadingMapListener(@NonNull MapView.OnDidFinishLoadingMapListener listener)
listener
- The callback that's invoked when the map has finished loadingpublic void addOnDidFailLoadingMapListener(@NonNull MapView.OnDidFailLoadingMapListener listener)
listener
- The callback that's invoked when the map failed to loadpublic void removeOnDidFailLoadingMapListener(@NonNull MapView.OnDidFailLoadingMapListener listener)
listener
- The callback that's invoked when the map failed to loadpublic void addOnWillStartRenderingFrameListener(@NonNull MapView.OnWillStartRenderingFrameListener listener)
listener
- The callback that's invoked when the camera will start rendering a framepublic void removeOnWillStartRenderingFrameListener(@NonNull MapView.OnWillStartRenderingFrameListener listener)
listener
- The callback that's invoked when the camera will start rendering a framepublic void addOnDidFinishRenderingFrameListener(@NonNull MapView.OnDidFinishRenderingFrameListener listener)
listener
- The callback that's invoked when the map has finished rendering a framepublic void removeOnDidFinishRenderingFrameListener(@NonNull MapView.OnDidFinishRenderingFrameListener listener)
listener
- The callback that's invoked when the map has finished rendering a framepublic void addOnWillStartRenderingMapListener(@NonNull MapView.OnWillStartRenderingMapListener listener)
listener
- The callback that's invoked when the map will start renderingpublic void removeOnWillStartRenderingMapListener(@NonNull MapView.OnWillStartRenderingMapListener listener)
listener
- The callback that's invoked when the map will start renderingpublic void addOnDidFinishRenderingMapListener(@NonNull MapView.OnDidFinishRenderingMapListener listener)
listener
- The callback that's invoked when the map has finished renderingpublic void removeOnDidFinishRenderingMapListener(MapView.OnDidFinishRenderingMapListener listener)
listener
- The callback that's invoked when the map has has finished rendering.public void addOnDidBecomeIdleListener(@NonNull MapView.OnDidBecomeIdleListener listener)
listener
- The callback that's invoked when the map has entered the idle state.public void removeOnDidBecomeIdleListener(@NonNull MapView.OnDidBecomeIdleListener listener)
listener
- The callback that's invoked when the map has entered the idle state.public void addOnDidFinishLoadingStyleListener(@NonNull MapView.OnDidFinishLoadingStyleListener listener)
listener
- The callback that's invoked when the style has finished loadingpublic void removeOnDidFinishLoadingStyleListener(@NonNull MapView.OnDidFinishLoadingStyleListener listener)
listener
- The callback that's invoked when the style has finished loadingpublic void addOnSourceChangedListener(@NonNull MapView.OnSourceChangedListener listener)
listener
- The callback that's invoked when the source has changedpublic void removeOnSourceChangedListener(@NonNull MapView.OnSourceChangedListener listener)
listener
- The callback that's invoked when the source has changedpublic void addOnStyleImageMissingListener(@NonNull MapView.OnStyleImageMissingListener listener)
listener
- The callback that's invoked when the id of an icon is missingpublic void removeOnStyleImageMissingListener(@NonNull MapView.OnStyleImageMissingListener listener)
listener
- The callback that's invoked when the source has changedpublic void addOnCanRemoveUnusedStyleImageListener(@NonNull MapView.OnCanRemoveUnusedStyleImageListener listener)
A callback will be called only for unused images that were provided by the client via
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.
listener
- The callback that's invoked when map needs to release unused image resourcespublic void removeOnCanRemoveUnusedStyleImageListener(@NonNull MapView.OnCanRemoveUnusedStyleImageListener listener)
When all listeners are removed, platform will fallback to default behavior, which is to remove unused images from the style.
listener
- The callback that's invoked when map needs to release unused image resources@UiThread public void getMapAsync(@NonNull OnMapReadyCallback callback)
TrimbleMapsMap
instance is ready to be used.callback
- The callback object that will be triggered when the map is ready to be used.public static void setMapStrictModeEnabled(boolean strictModeEnabled)
MapStrictModeException
whenever the map would fail silently otherwise.strictModeEnabled
- true to enable the strict mode, false otherwise