public class MapController extends Object implements IMapController, GLSurfaceView.Renderer
MapController
is the main class for interacting with a Tangram map.Modifier and Type | Class and Description |
---|---|
static class |
MapController.CameraType
Options for changing the appearance of 3D geometry
|
static class |
MapController.CompassVisibility
Options for compass visibility
|
static class |
MapController.EaseType
Options for interpolating map parameters
|
static interface |
MapController.FrameCaptureCallback
|
static interface |
MapController.MarkerPickListener
Interface for a callback to receive the selected
Marker
Triggered after a call of MapController.pickMarker(float, float)
Listener should be set with MapController.setMarkerPickListener(MarkerPickListener)
The callback will be run on the main (UI) thread. |
static interface |
MapController.ViewCompleteListener
Called on the UI thread when the view is stationary, fully loaded, and no animations are running.
|
Modifier | Constructor and Description |
---|---|
protected |
MapController(MapView view,
ConfigurationManager configurationManager)
Construct a MapController using a custom scene file.
|
Modifier and Type | Method and Description |
---|---|
Marker |
addMarker(LatLng coordinates,
MapObjectStyle style)
Adds a
Marker to the map which can be used to dynamically add points and polylines
to the map. |
Polygon |
addPolygon(GeoPointsList geoPointsList,
PolygonStyle style)
Adds a
Polygon to the map. |
Polyline |
addPolyline(GeoPointsList geoPointsList,
PolylineStyle style)
Adds a
Polyline to the map. |
void |
captureFrame(MapController.FrameCaptureCallback callback,
boolean waitForCompleteView)
Capture MapView as Bitmap.
|
Set<Polygon> |
getAllPolygons()
Gets a copy of all polygons that are currently on the map
|
Set<Polyline> |
getAllPolylines()
Gets a copy of all polylines that are currently on the map
|
CameraPosition |
getCameraPosition()
Returns the camera position.
|
MapController.CameraType |
getCameraType()
Get the camera type currently in use for the map view.
|
float |
getMaxTiltRad()
Returns the maximum tilt angle of the view, in radians.
|
RelativeLayout |
getOverlaysParent()
Returns the map's overlay layout, into which various statically-positioned views can be
added.
|
LatLng |
getPosition()
Get the geographic position of the center of the map view.
|
float |
getRotationDeg()
Get the rotation of the view, in degrees.
|
float |
getRotationRad()
Get the rotation of the view, normalized to 0-2*PI.
|
float |
getTiltRad()
Get the tilt angle of the view, Normalized to 0-PI/2.
|
UserLocationMarkerManager |
getUserLocationMarkerManager()
Returns the manager of the user location marker.
|
float |
getZoom()
Get the zoom level of the map view.
|
boolean |
hasPolygons()
Checks if the map contains polygons
|
boolean |
hasPolylines()
Checks if the map contains polylines
|
boolean |
isRotateGesturesEnabled()
Are rotation gestures enabled
|
boolean |
isScrollGesturesEnabled()
Whether the map should support scrolling gestures (pan)
|
boolean |
isTiltGesturesEnabled()
Are tilt gestures enabled
|
boolean |
isZoomGesturesEnabled()
Are zoom gestures enabled
|
PointF |
latLngToScreenPosition(LatLng location)
Find the position on screen corresponding to the given geographic coordinates.
|
void |
pickFeature(float posX,
float posY)
Query the map for geometry features at the given screen coordinates; results will be returned
in a callback to the object set by
MapController.setFeaturePickListener(FeaturePickListener) . |
void |
pickLabel(float posX,
float posY)
Query the map for labeled features at the given screen coordinates; results will be returned
in a callback to the object set by
MapController.setLabelPickListener(LabelPickListener) . |
void |
pickMarker(float posX,
float posY)
Query the map for a
Marker at the given screen coordinates; results will be returned
in a callback to the object set by MapController.setMarkerPickListener(MarkerPickListener) . |
void |
refreshLoadingTiles()
If some tiles might still be in loading state, this method will refresh them, so that they will be re-sent.
|
void |
removeAllMarkers()
Remove all the
Marker objects from the map. |
void |
removeAllPolygons()
Removes all polygons
|
void |
removeAllPolylines()
Removes all polylines
|
void |
removeMarker(Marker marker)
Removes the passed in
Marker from the map. |
void |
removePolygon(Polygon polygon)
Removes a polygon.
|
void |
removePolyline(Polyline polyline)
Removes a polyline.
|
LatLng |
screenPositionToLatLng(float x,
float y)
Find the geographic coordinates corresponding to the given position on the screen.
|
LatLng |
screenPositionToLatLng(PointF screenPosition)
Find the geographic coordinates corresponding to the given position on the screen.
|
void |
setCameraPosition(CameraPosition pos)
Sets the camera position to the given one.
|
void |
setCameraPositionEased(CameraPosition pos,
int duration)
Sets the camera position to the given one, with the default easing of the given duration.
|
void |
setCameraPositionEased(CameraPosition pos,
int duration,
MapController.EaseType ease)
Sets the camera position to the given one, with the default easing of the given duration.
|
void |
setCameraType(MapController.CameraType type)
Set the camera type for the map view.
|
void |
setCompassView(CompassView compassView)
Sets a custom compass view.
|
void |
setCompassView(int layoutResId)
Sets a custom
CompassView . |
void |
setCompassVisibility(MapController.CompassVisibility compassVisibility)
Sets the visibility mode of the compass.
|
void |
setDefaultBackgroundColor(float red,
float green,
float blue)
Sets an opaque background color used as default color when a scene is being loaded.
|
void |
setDoubleTapResponder(TouchInput.DoubleTapResponder responder)
Set a responder for double-tap gestures.
|
void |
setFeaturePickListener(com.here.mobility.sdk.map.MapController.FeaturePickListener listener)
Set a listener for feature pick events.
|
void |
setLabelPickListener(com.here.mobility.sdk.map.MapController.LabelPickListener listener)
Set a listener for label pick events, set null to stop listener.
|
void |
setLongPressResponder(TouchInput.LongPressResponder responder)
Set a responder for long press gestures
|
void |
setMarkerPickListener(MapController.MarkerPickListener listener)
Set a listener for marker pick events, set null to stop listener.
|
void |
setMaxTiltRad(float maxTilt)
Set the maximum tilt angle of the view.
|
void |
setPanResponder(TouchInput.PanResponder responder)
Set a responder for pan gestures
|
void |
setPickRadius(float radius)
Set the radius to use when picking features on the map.
|
void |
setPosition(LatLng position)
Set the geographic position of the center of the map view.
|
void |
setPositionEased(LatLng position)
Set the geographic position of the center of the map view with default easing.
|
void |
setPositionEased(LatLng position,
long duration)
Set the geographic position of the center of the map view with default easing.
|
void |
setPositionEased(LatLng position,
long duration,
MapController.EaseType ease)
Set the geographic position of the center of the map view with custom easing.
|
void |
setRotateGesturesEnabled(boolean isEnabled)
Sets whether the map should support rotation gestures.
|
void |
setRotateResponder(TouchInput.RotateResponder responder)
Set a responder for rotate gestures.
|
void |
setRotationRad(float rotation)
Set the rotation of the view.
|
void |
setRotationRadEased(float rotation)
Set the rotation of the view with the default duration (proportional to the rotation amount)
|
void |
setRotationRadEased(float rotation,
long duration)
Set the rotation of the view with default easing.
|
void |
setRotationRadEased(float rotation,
long duration,
MapController.EaseType ease)
Set the rotation of the view with custom easing.
|
void |
setScaleResponder(TouchInput.ScaleResponder responder)
Set a responder for scale gestures.
|
void |
setScrollGesturesEnabled(boolean isEnabled)
Sets whether the map should support scrolling gestures (pan).
|
void |
setShoveResponder(TouchInput.ShoveResponder responder)
Set a responder for shove (vertical two-finger drag) gestures.
|
void |
setSimultaneousGestureAllowed(TouchInput.Gestures first,
TouchInput.Gestures second,
boolean allowed)
Set whether the gesture
second can be recognized while first is in progress. |
void |
setTapResponder(TouchInput.TapResponder tapResponder)
Set the map's tap responder.
|
void |
setTiltGesturesEnabled(boolean isEnabled)
Sets whether the map should support tilt gestures.
|
void |
setTiltRad(float tilt)
Set the tilt angle of the view.
|
void |
setTiltRadEased(float tilt)
Set the tilt angle of the view with the default duration (proportional to the tilt amount)
|
void |
setTiltRadEased(float tilt,
long duration)
Set the tilt angle of the view with default easing.
|
void |
setTiltRadEased(float tilt,
long duration,
MapController.EaseType ease)
Set the tilt angle of the view with custom easing.
|
void |
setTwoFingerTapResponder(TouchInput.TwoFingerTapResponder responder)
Set a responder for two-finger tap gestures.
|
void |
setViewCompleteListener(MapController.ViewCompleteListener listener)
Set a listener for view complete events.
|
void |
setZoom(float zoom)
Set the zoom level of the map view.
|
void |
setZoomEased(float zoom)
Set the zoom level of the map view with default easing.
|
void |
setZoomEased(float zoom,
long duration)
Set the zoom level of the map view with default easing.
|
void |
setZoomEased(float zoom,
long duration,
MapController.EaseType ease)
Set the zoom level of the map view with custom easing
|
void |
setZoomGesturesEnabled(boolean isEnabled)
Sets whether the map should support zoom gestures.
|
void |
showBoundingBox(GeoBox box)
Set the position and zoom of the map such that the given bounding box is visible.
|
void |
showBoundingBox(GeoBox box,
Rect padding)
Set the position and zoom of the map such that the given bounding box is visible.
|
void |
showBoundingBoxEased(GeoBox box,
Rect padding,
int duration)
Like
MapController.showBoundingBox(GeoBox, Rect) , but with an animation of the given length, in
milliseconds. |
void |
showBoundingBoxEased(GeoBox box,
Rect padding,
int duration,
MapController.EaseType ease)
Like
MapController.showBoundingBox(GeoBox, Rect) , but with an animation of the given type and
length, in milliseconds. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onDrawFrame, onSurfaceChanged, onSurfaceCreated
protected MapController(MapView view, ConfigurationManager configurationManager)
view
- The view displaying the map; input events from this
view will be handled by the MapController's TouchInput gesture detector.
It also provides the Context in which the map will function; the asset
bundle for this activity must contain all the local files that the map
will need.public void captureFrame(MapController.FrameCaptureCallback callback, boolean waitForCompleteView)
captureFrame
in interface IMapController
waitForCompleteView
- Delay the capture until the view is fully loaded and
no ease- or label-animation is running.public void setCameraPosition(CameraPosition pos)
setCameraPosition
in interface IMapController
pos
- The camera position to set.public void setCameraPositionEased(CameraPosition pos, int duration)
setCameraPositionEased
in interface IMapController
pos
- The camera position to set.duration
- Time in milliseconds to ease to the given positionpublic void setCameraPositionEased(CameraPosition pos, int duration, MapController.EaseType ease)
setCameraPositionEased
in interface IMapController
pos
- The camera position to set.duration
- Time in milliseconds to ease to the given positionpublic CameraPosition getCameraPosition()
getCameraPosition
in interface IMapController
public void setPosition(LatLng position)
setPosition
in interface IMapController
position
- LatLng
of the position to setpublic void setPositionEased(LatLng position, long duration)
setPositionEased
in interface IMapController
position
- LatLng
of the position to setduration
- Time in milliseconds to ease to the given positionpublic void setPositionEased(LatLng position)
setPositionEased
in interface IMapController
position
- LatLng
of the position to setpublic void setPositionEased(LatLng position, long duration, MapController.EaseType ease)
setPositionEased
in interface IMapController
position
- LatLng
of the position to setduration
- Time in milliseconds to ease to the given positionease
- Type of easing to usepublic LatLng getPosition()
getPosition
in interface IMapController
LatLng
public void showBoundingBox(GeoBox box)
showBoundingBox
in interface IMapController
public void showBoundingBox(GeoBox box, Rect padding)
showBoundingBox
in interface IMapController
public void showBoundingBoxEased(GeoBox box, Rect padding, int duration)
MapController.showBoundingBox(GeoBox, Rect)
, but with an animation of the given length, in
milliseconds.showBoundingBoxEased
in interface IMapController
public void showBoundingBoxEased(GeoBox box, Rect padding, int duration, MapController.EaseType ease)
MapController.showBoundingBox(GeoBox, Rect)
, but with an animation of the given type and
length, in milliseconds.showBoundingBoxEased
in interface IMapController
public void setZoom(float zoom)
setZoom
in interface IMapController
zoom
- Zoom level; lower values show more areapublic void setZoomEased(float zoom)
setZoomEased
in interface IMapController
zoom
- Zoom level; lower values show more areapublic void setZoomEased(float zoom, long duration)
setZoomEased
in interface IMapController
zoom
- Zoom level; lower values show more areaduration
- Time in milliseconds to ease to given zoompublic void setZoomEased(float zoom, long duration, MapController.EaseType ease)
setZoomEased
in interface IMapController
zoom
- Zoom level; lower values show more areaduration
- Time in milliseconds to ease to given zoomease
- Type of easing to usepublic float getZoom()
getZoom
in interface IMapController
public void setRotationRad(float rotation)
setRotationRad
in interface IMapController
rotation
- Counter-clockwise rotation in radians; 0 corresponds to North pointing uppublic void setRotationRadEased(float rotation)
setRotationRadEased
in interface IMapController
rotation
- Counter-clockwise rotation in radians; 0 corresponds to North pointing uppublic void setRotationRadEased(float rotation, long duration)
setRotationRadEased
in interface IMapController
rotation
- Counter-clockwise rotation in radians; 0 corresponds to North pointing upduration
- Time in milliseconds to ease to the given rotationpublic void setRotationRadEased(float rotation, long duration, MapController.EaseType ease)
setRotationRadEased
in interface IMapController
rotation
- Counter-clockwise rotation in radians; 0 corresponds to North pointing upduration
- Time in milliseconds to ease to the given rotationease
- Type of easing to usepublic float getRotationRad()
getRotationRad
in interface IMapController
public float getRotationDeg()
getRotationDeg
in interface IMapController
public void setMaxTiltRad(float maxTilt)
setMaxTiltRad
in interface IMapController
maxTilt
- angle in radians; 0 corresponds to straight downpublic float getMaxTiltRad()
getMaxTiltRad
in interface IMapController
public void setTiltRad(float tilt)
setTiltRad
in interface IMapController
tilt
- Tilt angle in radians; 0 corresponds to straight downpublic void setTiltRadEased(float tilt)
setTiltRadEased
in interface IMapController
tilt
- Tilt angle in radians; 0 corresponds to straight downpublic void setTiltRadEased(float tilt, long duration)
setTiltRadEased
in interface IMapController
tilt
- Tilt angle in radians; 0 corresponds to straight downduration
- Time in milliseconds to ease to the given tiltpublic void setTiltRadEased(float tilt, long duration, MapController.EaseType ease)
setTiltRadEased
in interface IMapController
tilt
- Tilt angle in radians; 0 corresponds to straight downduration
- Time in milliseconds to ease to the given tiltease
- Type of easing to usepublic float getTiltRad()
getTiltRad
in interface IMapController
public void setCameraType(MapController.CameraType type)
setCameraType
in interface IMapController
type
- A CameraType
public MapController.CameraType getCameraType()
getCameraType
in interface IMapController
CameraType
public LatLng screenPositionToLatLng(PointF screenPosition)
screenPositionToLatLng
in interface IMapController
screenPosition
- Position in pixels from the top-left corner of the map areaLatLng
corresponding to the given point, or null if the screen position
does not intersect a geographic location (this can happen at high tilt angles).public LatLng screenPositionToLatLng(float x, float y)
screenPositionToLatLng
in interface IMapController
x
- Position on the X axis, in pixels from the top-left corner of the map areay
- Position on the Y axis, in pixels from the top-left corner of the map areaLatLng
corresponding to the given point, or null if the screen position
does not intersect a geographic location (this can happen at high tilt angles).public PointF latLngToScreenPosition(LatLng location)
latLngToScreenPosition
in interface IMapController
location
- Geographic coordinatespublic void setScrollGesturesEnabled(boolean isEnabled)
setScrollGesturesEnabled
in interface IMapController
isEnabled
- is scrolling gestures should be enabledpublic boolean isScrollGesturesEnabled()
isScrollGesturesEnabled
in interface IMapController
public void setRotateGesturesEnabled(boolean isEnabled)
setRotateGesturesEnabled
in interface IMapController
isEnabled
- set to true to enable rotation gestures; false to disablepublic boolean isRotateGesturesEnabled()
isRotateGesturesEnabled
in interface IMapController
public void setTiltGesturesEnabled(boolean isEnabled)
setTiltGesturesEnabled
in interface IMapController
isEnabled
- set to true to enable tilt gestures; false to disablepublic boolean isTiltGesturesEnabled()
isTiltGesturesEnabled
in interface IMapController
public void setZoomGesturesEnabled(boolean isEnabled)
setZoomGesturesEnabled
in interface IMapController
isEnabled
- set to true to enable zoom gestures; false to disablepublic boolean isZoomGesturesEnabled()
isZoomGesturesEnabled
in interface IMapController
public void setTapResponder(TouchInput.TapResponder tapResponder)
setTapResponder
in interface IMapController
tapResponder
- TapResponder to callpublic void setDoubleTapResponder(TouchInput.DoubleTapResponder responder)
setDoubleTapResponder
in interface IMapController
responder
- DoubleTapResponder to callpublic void setTwoFingerTapResponder(TouchInput.TwoFingerTapResponder responder)
setTwoFingerTapResponder
in interface IMapController
responder
- TwoFingerTapResponder to callpublic void setLongPressResponder(TouchInput.LongPressResponder responder)
setLongPressResponder
in interface IMapController
responder
- LongPressResponder to callpublic void setPanResponder(TouchInput.PanResponder responder)
setPanResponder
in interface IMapController
responder
- PanResponder to call; if onPan returns true, normal panning behavior will not occurpublic void setRotateResponder(TouchInput.RotateResponder responder)
setRotateResponder
in interface IMapController
responder
- RotateResponder to call; if onRotate returns true, normal rotation behavior will not occurpublic void setScaleResponder(TouchInput.ScaleResponder responder)
setScaleResponder
in interface IMapController
responder
- ScaleResponder to call; if onScale returns true, normal scaling behavior will not occurpublic void setShoveResponder(TouchInput.ShoveResponder responder)
setShoveResponder
in interface IMapController
responder
- ShoveResponder to call; if onShove returns true, normal tilting behavior will not occurpublic void setSimultaneousGestureAllowed(TouchInput.Gestures first, TouchInput.Gestures second, boolean allowed)
second
can be recognized while first
is in progress.setSimultaneousGestureAllowed
in interface IMapController
first
- Initial gesture typesecond
- Subsequent gesture typeallowed
- True if second
should be recognized, else falsepublic void setPickRadius(float radius)
setPickRadius
in interface IMapController
radius
- The radius in dp (density-independent pixels).public void setFeaturePickListener(com.here.mobility.sdk.map.MapController.FeaturePickListener listener)
setFeaturePickListener
in interface IMapController
listener
- The FeaturePickListener
to callpublic void setLabelPickListener(com.here.mobility.sdk.map.MapController.LabelPickListener listener)
setLabelPickListener
in interface IMapController
listener
- The LabelPickListener
to callpublic void setMarkerPickListener(MapController.MarkerPickListener listener)
setMarkerPickListener
in interface IMapController
listener
- The MapController.MarkerPickListener
to callpublic void pickFeature(float posX, float posY)
MapController.setFeaturePickListener(FeaturePickListener)
.pickFeature
in interface IMapController
posX
- The horizontal screen coordinateposY
- The vertical screen coordinatepublic void pickLabel(float posX, float posY)
MapController.setLabelPickListener(LabelPickListener)
.pickLabel
in interface IMapController
posX
- The horizontal screen coordinateposY
- The vertical screen coordinatepublic void pickMarker(float posX, float posY)
Marker
at the given screen coordinates; results will be returned
in a callback to the object set by MapController.setMarkerPickListener(MarkerPickListener)
.pickMarker
in interface IMapController
posX
- The horizontal screen coordinateposY
- The vertical screen coordinatepublic Marker addMarker(LatLng coordinates, MapObjectStyle style)
Marker
to the map which can be used to dynamically add points and polylines
to the map.addMarker
in interface IMapController
coordinates
- the initial coordinates of the markerstyle
- the style of the markerMarker
object.public Polygon addPolygon(GeoPointsList geoPointsList, PolygonStyle style)
Polygon
to the map.addPolygon
in interface IMapController
geoPointsList
- the polygon's geometrystyle
- the polygon's style. if null, a default style will be createdMapController.removePolygon(Polygon)
.public void removePolygon(Polygon polygon)
removePolygon
in interface IMapController
polygon
- the polygon to be removedpublic void removeAllPolygons()
removeAllPolygons
in interface IMapController
public Set<Polygon> getAllPolygons()
getAllPolygons
in interface IMapController
public boolean hasPolygons()
hasPolygons
in interface IMapController
public Polyline addPolyline(GeoPointsList geoPointsList, PolylineStyle style)
Polyline
to the map.addPolyline
in interface IMapController
geoPointsList
- the polyline's geometrystyle
- the polyline's style. if null, a default style will be createdMapController.removePolyline(Polyline)
.public void removePolyline(Polyline polyline)
removePolyline
in interface IMapController
polyline
- the polyline to be removedpublic void removeAllPolylines()
removeAllPolylines
in interface IMapController
public Set<Polyline> getAllPolylines()
getAllPolylines
in interface IMapController
public boolean hasPolylines()
hasPolylines
in interface IMapController
public void removeMarker(Marker marker)
Marker
from the map.removeMarker
in interface IMapController
marker
- to remove from the map.public void removeAllMarkers()
Marker
objects from the map.removeAllMarkers
in interface IMapController
public void setViewCompleteListener(MapController.ViewCompleteListener listener)
setViewCompleteListener
in interface IMapController
listener
- The MapController.ViewCompleteListener
to call when the view is completepublic RelativeLayout getOverlaysParent()
getOverlaysParent
in interface IMapController
public void setDefaultBackgroundColor(float red, float green, float blue)
setDefaultBackgroundColor
in interface IMapController
red
- red component of the background color - a value between 0 and 1.0green
- green component of the background color - a value between 0 and 1.0blue
- blue component of the background color - a value between 0 and 1.0public UserLocationMarkerManager getUserLocationMarkerManager()
getUserLocationMarkerManager
in interface IMapController
public void setCompassVisibility(MapController.CompassVisibility compassVisibility)
MapController.CompassVisibility.VISIBLE_ALWAYS
- the compass is always visibleMapController.CompassVisibility.HIDDEN_ALWAYS
- the compass is never visibleMapController.CompassVisibility.VISIBLE_WHEN_MAP_ROTATED
- the compass is visible only
when the rotation of the map is not 0setCompassVisibility
in interface IMapController
public void setCompassView(int layoutResId)
CompassView
. This layout root element of the layout must be an instance
of CompassView
. It will be added into the overlays parent
, which is a RelativeLayout
.
Use a value of 0
to reset to the default compass view.setCompassView
in interface IMapController
public void setCompassView(CompassView compassView)
null
value to reset to the default one.setCompassView
in interface IMapController
public void refreshLoadingTiles()