public interface OSMap
OSMap
object directly, rather, you must obtain one from the MapView.getMap()
method on a
MapFragment
or MapView
that you have added to your application.
Note: Similar to a android.view.View View object, an OSMap
can only be read and modified from the main thread.
Calling OSMap
methods from another thread may result in an exception.
Developer Guide
To get started, read Google Maps Developer Guide
OSMap
closely follows the Google Maps Android v2 interface, and therefore the documentation for that API
is the best starting point for users of this class.
The following classes in Google Maps have no equivalent in OS Map
In, the following features of Google Maps are not supported
Modifier and Type | Interface and Description |
---|---|
static interface |
OSMap.InfoWindowAdapter
Methods on this provider are called when it is time to show an info window for a marker, regardless of the cause
(either a user gesture or a programmatic call to
Marker.showInfoWindow() . |
static interface |
OSMap.OnCameraChangeListener
Defines signatures for methods that are called when the camera changes position.
|
static interface |
OSMap.OnInfoWindowClickListener
Callback interface for click/tap events on a marker's info window.
|
static interface |
OSMap.OnMapClickListener
Callback interface for when the user taps on the map.
|
static interface |
OSMap.OnMapLongClickListener
Callback interface for when the user long presses on the map.
|
static interface |
OSMap.OnMarkerClickListener
Defines signatures for methods that are called when a marker is clicked or tapped.
|
static interface |
OSMap.OnMarkerDragListener
Callback interface for drag events on markers.
|
static interface |
OSMap.OnMyLocationChangeListener
Callback interface for when the My Location dot (which signifies the user's location) changes location.
|
Modifier and Type | Method and Description |
---|---|
Circle |
addCircle(CircleOptions options)
Add a circle to this map.
|
Marker |
addMarker(MarkerOptions options)
Adds a marker to this map.
|
Polygon |
addPolygon(PolygonOptions options)
Adds a polygon to this map.
|
Polyline |
addPolyline(PolylineOptions options)
Adds a polyline to this map.
|
void |
clear()
Removes all markers, overlays, and polylines from the map.
|
GridPoint |
getMyGridPoint()
Convenience method to get current user location as a
GridPoint |
android.location.Location |
getMyLocation()
Returns the currently displayed user location, or null if there is no location data available.
|
boolean |
isMyLocationEnabled()
Gets the status of the my-location layer.
|
OSTileSource |
localTileSource(android.content.Context context,
File file) |
Collection<OSTileSource> |
localTileSourcesInDirectory(android.content.Context context,
File dir) |
void |
moveCamera(CameraPosition camera,
boolean animated) |
void |
setInfoWindowAdapter(OSMap.InfoWindowAdapter adapter)
Sets a custom renderer for the contents of info windows.
|
void |
setLocationSource(LocationSource source)
Replaces the location source of the my-location layer
|
void |
setMyLocationEnabled(boolean enabled)
Enables or disables the my-location layer.
|
void |
setOnCameraChangeListener(OSMap.OnCameraChangeListener listener)
Sets a callback that's invoked when the camera changes.
|
void |
setOnInfoWindowClickListener(OSMap.OnInfoWindowClickListener listener)
Sets a callback that's invoked when a marker info window is clicked.
|
void |
setOnMapClickListener(OSMap.OnMapClickListener listener)
Sets a callback that's invoked when the map is tapped
|
void |
setOnMapLongClickListener(OSMap.OnMapLongClickListener listener)
Sets a callback that's invoked when the map is long pressed.
|
void |
setOnMarkerClickListener(OSMap.OnMarkerClickListener listener)
Sets a callback that's invoked when a marker is clicked.
|
void |
setOnMarkerDragListener(OSMap.OnMarkerDragListener listener)
Sets a callback that's invoked when a marker is dragged.
|
void |
setOnMyLocationChangeListener(OSMap.OnMyLocationChangeListener listener)
Sets a callback that's invoked when the my location dot changes location.
|
void |
setTileSources(Collection<OSTileSource> tileSources) |
OSTileSource |
webTileSource(String apiKey,
boolean openSpacePro,
String[] productsOrNull) |
Marker addMarker(MarkerOptions options)
The marker's icon is rendered on the map at the location Marker.position. Clicking the marker centers the camera on the marker. If Marker.title is defined, the map shows an info box with the marker's title and snippet. If the marker is draggable, long-clicking and then dragging the marker moves it.
options
- A marker options object that defines how to render the marker.void clear()
Polyline addPolyline(PolylineOptions options)
options
- A polyline options object that defines how to render the Polyline.Polygon addPolygon(PolygonOptions options)
options
- A polygon options object that defines how to render the Polygon.Circle addCircle(CircleOptions options)
options
- A circle options object that defines how to render the Circlevoid setInfoWindowAdapter(OSMap.InfoWindowAdapter adapter)
Like the map's event listeners, this state is not serialized with the map. If the map gets re-created (e.g., due to a configuration change), you must ensure that you call this method again in order to preserve the customization.
adapter
- The adapter to use for info window contents, or null to use the default content rendering in info windows.void setOnInfoWindowClickListener(OSMap.OnInfoWindowClickListener listener)
listener
- The callback that's invoked when a marker info window is clicked. To unset the callback, use null.void setOnMapClickListener(OSMap.OnMapClickListener listener)
listener
- The callback that's invoked when the map is tapped. To unset the callback, use null.void setOnMapLongClickListener(OSMap.OnMapLongClickListener listener)
listener
- The callback that's invoked when the map is long pressed. To unset the callback, use null.void setOnMarkerClickListener(OSMap.OnMarkerClickListener listener)
listener
- The callback that's invoked when a marker is clicked. To unset the callback, use null.void setOnMarkerDragListener(OSMap.OnMarkerDragListener listener)
listener
- The callback that's invoked on marker drag events. To unset the callback, use null.boolean isMyLocationEnabled()
void setMyLocationEnabled(boolean enabled)
enabled
- True to enable; false to disable.android.location.Location getMyLocation()
GridPoint getMyGridPoint()
GridPoint
GridPoint
void setOnMyLocationChangeListener(OSMap.OnMyLocationChangeListener listener)
listener
- The callback that's invoked when the my location dot changes.void moveCamera(CameraPosition camera, boolean animated)
void setOnCameraChangeListener(OSMap.OnCameraChangeListener listener)
listener
- The callback that's invoked when the camera changes. To unset the callback, use null.void setLocationSource(LocationSource source)
source
- A location source to use in the my-location layer. Set to null to use the default location source.void setTileSources(Collection<OSTileSource> tileSources)
OSTileSource webTileSource(String apiKey, boolean openSpacePro, String[] productsOrNull)
apiKey
- openSpacePro
- productsOrNull
- only fetch products in this list. If null, then this parameter is ignoredOSTileSource localTileSource(android.content.Context context, File file) throws FailedToLoadException
FailedToLoadException
Collection<OSTileSource> localTileSourcesInDirectory(android.content.Context context, File dir)
Copyright © 2012–2013 Ordnance Survey. All rights reserved.