Skip to content
Andy edited this page Jun 5, 2013 · 13 revisions

Public Methods

Note: references to existing methods, for example overloads, are referring to the ArcGIS Runtime SDK for Android.

  • addLayer(MapType maptype,Double latitude, Double longitude, Double scale, Boolean visible)
  • clearDrawGraphicsLayer()
  • clearAllGraphics()
  • setBaseMapVisibility(MapType maptype)
  • layerExists(MapType maptype)
  • layerExists(GraphicsLayer graphicsLayer)
  • getCurrentVisibleLayerName()
  • findClosestGraphic(float x, float y,GraphicsLayer graphicsLayer,int tolerance)
  • addGraphicLatLon(double latitude, double longitude, Map<String, Object> attributes, SimpleMarkerSymbol.STYLE style)
  • addGraphicLine(String[] lineArray, SimpleLineSymbol.STYLE style, int color)
  • centerAt(double latitude, double longitude, boolean animated)
  • findAddress(String address)
  • findAddressByXY(float x, float y)
  • findAddressByLatLon(double latitude, double longitude)
  • displayToast(String message,int... toastLength)
  • setDrawType(DrawType drawType)
  • delayedStartLocationService(final boolean...gpsSnapshotMode)
  • stopLocationService(final Boolean... silent)
  • pause()
  • unpause()

Add a map

The addLayer() method is an overloaded method of [MapView](http://resources.arcgis.com/en/help/android-sdk/api/com/esri/android/map/MapView.html#addLayer(com.esri.android.map.Layer) that let's you create a map using some of the most common base map types. Maps are set using the MapType ENUM. Set the center of the map using latitude, longitude and scale determines how far in or out the map will be zoomed in when it loads. You can add more than one map, for example you could load both a Streets and Satellite layer. You can also specify visibility when using multiple maps. So if you add Streets you can set its visible property to true, and then when you add Satellite set its visible property to false. This way Streets will be the map that shows up when the app loads.

addLayer(MapType maptype,Double latitude, Double longitude, Double scale, Boolean visible)

This method returns an ArcGISTiledMapServiceLayer.

Clear drawing from map

The clearDrawGraphicsLayer() method removes any drawings that were made to the map using the draw tool.

clearDrawGraphicLayer()

This method returns void.

Clear all graphics

Added in v1.2. The clearAllGraphics() method removes any drawings that were made to the map using the draw tool or any graphics added programmatically.

clearAllGraphics()

This method returns void.

Change Map Visibility

When you have multiple maps the setBaseMapVisibility() method lets you easily toggle which map is visible. This provides you a way to quickly set visibility without having to instantiate a reference to the map. Compare to Layer.setVisibile().

setBaseMapVisibility(MapType maptype)

This method returns void.

Check if a map layer exists

layerExists() lets you verify a map layer exists and has been fully initialized before performing an operation against it. Compare to Layer.isInitialized().

layerExists(MapType maptype)

This method returns Boolean.

Check if a drawing/Graphics layer exists

layerExists() lets you verify a drawing (or Graphics) layer exists and has been fully initialized before performing an operation against it.

layerExists(GraphicsLayer graphicsLayer)

This method returns Boolean.

Get the current visible map name.

getCurrentVisibileLayerName() lets you programmatically determine which of the internal mapping layers is visible.

getCurrentVisibleLayerName()

This method returns String.

Find the closes Graphic based on a user touching the map.

findClosestGraphic() simplifies finding the nearest point. An example use case is when you are displaying multiple coffee shops and you want to return a reference to the Graphic that is closest to where the user touches the map. Compare to GraphicsLayer.getGraphicsIDs().

findClosestGraphic(float x, float y,GraphicsLayer graphicsLayer,int tolerance)

This method returns the Graphic.

Adding a graphic to the map by latitude and longitude.

addGraphicLatLon() provides an easy way to use lats and lons to create a Graphic. Compare to GraphicsLayer.addGraphic().

addGraphicLatLon(double latitude, double longitude, Map attributes, SimpleMarkerSymbol.STYLE style)

This method returns void.

Draw a line via latitude and longitude coordinates

addGraphicLine() lets you take a String array of lats and lons and create a simple line on the map. Compare to GraphicsLayer.addGraphic().

addGraphicLine(String[] lineArray, SimpleLineSymbol.STYLE style, int color)

This method returns void.

Center the map via latitude and longitude

centerAt() is an overloaded method of MapView that lets you center the map using a latitude and longitude coordinate.

centerAt(double latitude, double longitude, boolean animated)

This method returns void.

Find an address

Quickest way to programmatically find an address.

findAddress(String address)

This method returns void.

Find an address by touching map

findAddressByXY(float x, float y)

This method returns void.

Find an address by latitude and longitude

findAddressByLatLon(double latitude, double longitude)

This method returns void.

Repetitively display a toast message

displayToast() gives you a single line pattern that can be used for repetitive tasks that require toast messages.

displayToast(String message,int... toastLength)

This method returns void.

Specify a point, line or polygon draw type.

setDrawType() lets you use a single line pattern for specifying whether you want to draw a point, line or polygon.

setDrawType(DrawType drawType)

This method returns void.

Starting GPS (threadsafe)

delayedStartLocationService() provides an easy and safe way of starting the GPS that automatically checks that the map has been initialized before starting to use GPS coordinates to manipulate the map. It also provides a snapshot mode that will allow the GPS accuracy to settle to a predetermined point and then automatically shutdown.

delayedStartLocationService(final boolean...gpsSnapshotMode)

This method returns void.

Stopping GPS (threadsafe)

stopLocationService() attempts to stop the location service and throws an error event after a fixed number of unsuccessful attempts.

stopLocationService(final Boolean... silent)

This method returns void.

Pause the map

pause() is an overloaded method of MapView that lets you gracefully pause map operations during the application lifecycle.

pause()

This method returns void.

Unpause the map

unpause() is an overloaded method of MapView that lets you gracefully unpause the map operations during the application lifecycle.

unpause()

This method returns void.


Event Listeners

Add QuickStart event listeners

addEventListener(EsriQuickStartEventListener listener)

This method returns void.

Remove QuickStart event listeners

removeEventListener(EsriQuickStartEventListener listener)

This method returns void.

Restore the default map touch listener.

Use this in conjunction with the setDrawTouchListener().

setDefaultTouchListener()

This method returns void.

Turn on map drawing listener

setDrawTouchListener() lets you enable drawing capabilities and lock the map so it doesn't move while the user is drawing.

setDrawTouchListener()

This method returns void.


Public Properties

Return an instance of the Map

getMapView() returns a references to the INTERNAL MapView instance.

getMapView()

This method returns MapView.

Check if location is enabled.

isLocationEnabled() provides a single line pattern for determining if GPS_PROVIDER is set.

isLocationEnabled()

isLocationEnabled()

This method returns boolean.

Check if location is started

isLocationStarted() returns whether or not the location service has been started.

isLocationStarted()

This method returns boolean.

Get reference to streets map

getStreetsLayer()

This method returns ArcGISTiledMapServiceLayer.

Get reference to topo map

getTopoLayer()

This method returns ArcGISTiledMapServiceLayer.

Get reference to satellite map

getSatelliteLayer()

This method returns ArcGISTiledMapServiceLayer.

Get reference to points layer

getPointsLayer()

This method returns GraphicsLayer.

Get reference to drawing layer

getDrawLayer()

This method returns GraphicsLayer.

Check if base map loaded

Lets you determine if the map is fully initialized and ready to be used.

isMapLoaded()

This method returns boolean.

Set the map type ENUM

Single line pattern for setting the map.


MapType.STREETS
MapType.TOPO
MapType.SATELLITE

This method returns enum.

Set the draw type ENUM

Single line pattern for setting the draw tool.


DrawType.POINT
DrawType.POLYLINE
DrawType.POLYGON

This method returns enum.