MapViewBase (API Reference)
Interface MapViewBase
- All Known Implementing Classes:
MapSurface,MapView
Represents the available public API from MapView.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceCallback for a pick request. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLifecycleListener(MapViewLifecycleListener lifecycleListener) Adds aMapViewLifecycleListenerto this map view.geoToViewCoordinates(GeoCoordinates geoCoordinates) Converts geographical coordinates to view coordinates (in pixels).Gets the camera to control the view for the map.intGets maximum render frame rate in frames per second.Gets the gestures control object.Gets theHereMapassociated with this map view.Gets the map context associated with this map view.Gets the map scene associated with this map view.doubleGets the pixel scale factor used by thisMapView.Gets the size of this map view in physical pixels.Returns the watermark size in physical pixels.booleanisValid()Returnstrueif this instance is valid,falseotherwise.voidpick(MapScene.MapPickFilter filter, Rectangle2D viewArea, MapViewBase.MapPickCallback callback) Returns all map content located inside the specified pick area.voidremoveLifecycleListener(MapViewLifecycleListener lifecycleListener) Removes aMapViewLifecycleListenerfrom this map view.voidsetFrameRate(int value) Sets maximum render frame rate in frames per second.voidsetWatermarkLocation(Anchor2D anchor, Point2D offset) Sets the position of the HERE logo watermark within the map view.viewToGeoCoordinates(Point2D viewCoordinates) Converts view coordinates (in pixels) to geographical coordinates.
-
Method Details
-
viewToGeoCoordinates
Converts view coordinates (in pixels) to geographical coordinates.
An optional altitude component of the resulting geographical coordinate is not set.
If the view coordinates specify a point above a horizon, then the result is geographical coordinates of the point on a horizon below the specified view coordinates.
The fog effect is ignored for the calculation, meaning that for the view point within the area covered by the fog, the result is geographical coordinates that would be displayed at the specified point if the fog effect was not applied.
If the render surface is not attached, it will return
null.- Parameters:
viewCoordinates-Point inside the view to convert.
- Returns:
The geographical coordinates under specified view point or
nullif there is no render surface attached.
-
geoToViewCoordinates
Converts geographical coordinates to view coordinates (in pixels).
If specified, altitude of the input coordinates is interpreted as altitude above sea level. If not specified, the input coordinates are interpreted as being on ground elevation. The above distinction is only relevant when 3D terrain feature is enabled.
The resulting view coordinates might be outside of current viewport, i.e. result might contain values less than zero or greater than view's dimensions.
If the render surface is not attached, it will return
null.- Parameters:
geoCoordinates-Geographical coordinates to convert.
- Returns:
The view coordinates of the specified geographical point or
nullif there is no render surface attached.
-
setWatermarkLocation
Sets the position of the HERE logo watermark within the map view.
By default, the watermark is aligned to the bottom-right corner of the view: Anchor2D(1.0, 1.0) and Point2D(-watermarkSize.width / 2, -watermarkSize.height / 2). It is recommended to change the default position only if necessary to avoid overlapping UI elements. The watermark should always be fully visible within the view. The anchor point on the watermark is its center (width/2, height/2), around which it will be placed in the map view. For map views smaller than 250 dip in both width and height, the watermark will not be shown.
- Parameters:
anchor-Anchor point in normalized view coordinates [0, 1]. Map view's origin at (0, 0) indicates a top-left corner of the map view. Out of boundary anchor point values will be clamped to the [0, 1] range.
offset-A horizontal and vertical offset (expressed in positive/negative pixel coordinates) that allows shifting the watermark from the anchor point position in one or the other direction. For the quadrant of values expressing visible part of the map view negative offset shifts the watermark to the direction of the origin, positive - away from it. For example, the offset of (-10, 5) will shift the watermark 10px to the left and 5px to the bottom. If specified offset will result in watermark being completely or partially out-of-view the offset will be adjusted internally so that watermark is fully visible. Offset is not being scaled when the map view size changes.
-
addLifecycleListener
Adds a
MapViewLifecycleListenerto this map view. Adding the same object multiple times has no effect.- Parameters:
lifecycleListener-An object to be notified of lifecycle events.
-
removeLifecycleListener
Removes a
MapViewLifecycleListenerfrom this map view. Trying to remove an object that was not added or was removed before has no effect.- Parameters:
lifecycleListener-An object to stop being notified of lifecycle events.
-
pick
void pick(@Nullable MapScene.MapPickFilter filter, @NonNull Rectangle2D viewArea, @NonNull MapViewBase.MapPickCallback callback) Returns all map content located inside the specified pick area. Content to be picked is specified by a pick content filter. The pick area is defined by a rectangle in map view coordinates in pixels, relative to the map view's origin at (0, 0) which indicates the top-left corner of the map view.
- Parameters:
filter-Filter for the map content to be picked. When a filter is not set all of the pickable content will be picked.
viewArea-The rectangular pixel area of the view inside which map content will be picked. View area is relative to the map view's origin at (0, 0) at the top-left corner of the map view.
callback-Callback to call with the result. This will be called on a main thread when pick operation completes.
-
isValid
boolean isValid()Returns
trueif this instance is valid,falseotherwise. It will be madeIt will be made invalid when the corresponding
SDKNativeEngineis destroyed.- Returns:
Indicates whether this instance is valid.
-
getCamera
Gets the camera to control the view for the map.
- Returns:
The camera to control the view for the map.
-
getGestures
Gets the gestures control object.
- Returns:
The gestures control object for setting up the capture of gestures.
-
getMapScene
Gets the map scene associated with this map view.
- Returns:
Map scene associated with this map view.
-
getMapContext
Gets the map context associated with this map view.
- Returns:
Map context associated with this map view.
-
getHereMap
Gets the
HereMapassociated with this map view.- Returns:
Here Map associated with this map view.
-
getViewportSize
Gets the size of this map view in physical pixels.
If internally the map view's render surface is not attached yet (see:
MapViewLifecycleListener), or after the map view has been destroyed then aSize2Dwith zero width and height is returned.- Returns:
The size of this map view in physical pixels.
-
getFrameRate
int getFrameRate()Gets maximum render frame rate in frames per second.
- Returns:
Maximum render frame rate in frames per second.
-
setFrameRate
void setFrameRate(int value) Sets maximum render frame rate in frames per second. Setting to 0 disables automatic rendering for this view. Setting negative values has no effect. The default value is 60 frames per second.
- Parameters:
value-Maximum render frame rate in frames per second.
-
getPixelScale
double getPixelScale()Gets the pixel scale factor used by this
MapView.It is used to support screen resolution and size independence. This value is a derivative of the device's screen pixel density and is a direct analog of
pixel density from DisplayMetrics.
It can be used to translate between physical pixels and
density-independent pixels
according to the formula:
dp = px / pixelScale.
- Returns:
The pixel scale factor used by this
MapView.Pixel scale is 0.0 if the map view is not initialized.
-
getWatermarkSize
Returns the watermark size in physical pixels.
- Returns:
Provides the size of the watermark in physical pixels.
-