Class MapView

All Implemented Interfaces:
Drawable.Callback, AccessibilityEventSource, KeyEvent.Callback, ViewManager, ViewParent, MeridianLocationManager.LocationUpdateListener, Directions.DirectionsRequestListener

Provides an interactive Meridian map surface with map and direction controls.

MapView generally should not be used directly and MapFragment should be used in its stead.

MapView uses OpenGL and is dependent on receiving an Activity's onPause, onResume and onDestroy in order to properly manage its context and state. An Activity that intends to use MapView should create an instance of it in onCreate and call that instances onPause, onResume and onDestroy methods during its own onPause, onResume and onDestroy methods.

For example:

```java public void onCreate(Bundle savedInstanceState) { mapView = new MapView(this) mapView.setAppKey(appKey); mapView.setMapKey(mapKey); setContentView(mapView); }

public void onResume() { super.onResume(); mapView.onResume(); }

public void onPause() { mapView.onPause(); super.onPause(); }

public void onDestroy() { mapView.onDestroy(); super.onDestroy(); }

  • Field Details

  • Constructor Details

  • Method Details

    • onPause

      public void onPause()
      Should be called whenever the Activity’s onPause that contains this instance is called.
    • onResume

      public void onResume()
      Should be called whenever the Activity’s onResume that contains this instance is called.
    • onDestroy

      public void onDestroy()
      Should be called whenever the Activity’s onDestroy that contains this instance is called.
    • setMapEventListener

      public void setMapEventListener(MapView.MapEventListener listener)
      Set the MapEventListener for this MapView.
      Parameters:
      listener - The MapView.MapEventListener for this MapView.
    • setMapClickEventListener

      public void setMapClickEventListener(MapView.MapClickEventListener listener)
      Set the MapClickEventListener for this MapView.
      Parameters:
      listener - The MapView.MapClickEventListener for this MapView.
    • setDirectionsEventListener

      public void setDirectionsEventListener(MapView.DirectionsEventListener listener)
      Set the DirectionsEventListener for this MapView.
      Parameters:
      listener - The MapView.DirectionsEventListener for this MapView.
    • setMarkerEventListener

      public void setMarkerEventListener(MapView.MarkerEventListener listener)
      Set the MarkerEventListener for this MapView.
      Parameters:
      listener - The MapView.MarkerEventListener for this MapView.
    • getAppKey

      public EditorKey getAppKey()
      Get the current app key
    • setAppKey

      public void setAppKey(EditorKey appKey)
      Set the app key for this instance.

      This can only be set once. If changing the app key is necessary, the MapView must be recreated.

      Parameters:
      appKey - The Editor key for the location.
      Throws:
      IllegalArgumentException - If the AppKey has already been set.
    • getMapKey

      public EditorKey getMapKey()
      Get the current map key
    • getMapInfo

      public MapInfo getMapInfo()
      Get the current loaded map
      Returns:
      The current MapInfo, may be null if no map has been loaded.
    • setMapKey

      public void setMapKey(EditorKey mapKey)
      Set the map, this will start the process of loading and displaying a map.
      Parameters:
      mapKey - The editor key for the map
      Throws:
      IllegalArgumentException - if no AppKey has been set or the MapKey passed is not a child of the set AppKey
    • setPlacemarkId

      public void setPlacemarkId(String placemarkId)
      When a Placemark ID is set, the map will only show that Placemark.
      Parameters:
      placemarkId - Placemark ID to show on the map
    • setMaxZoomScale

      public void setMaxZoomScale(double scale)
      Set the current maximum zoom scale of the map view.

      Setting this to zero will force the default max zoom level to be used.

      Parameters:
      scale - The zoom scale to use.
    • getMaxZoomScale

      public double getMaxZoomScale()
      Get the current maximum zoom scale of the map view.
    • getPlacemarks

      public List<Placemark> getPlacemarks()
      Get a copy of the currently-loaded list of Placemarks for this map.

      This list may be empty until the onMapLoadFinish() listener method is called.

      Returns:
      List of Placemarks on the map.
    • getAllMarkers

      public List<Marker> getAllMarkers()
      Get a copy of the current list of Markers for this map.

      This list does include markers generated by the MapView from Placemarks and user created markers.

      Returns:
      List of all Markers on the map.
    • getUserMarkers

      public List<Marker> getUserMarkers()
      Get a copy of the current list of Markers for this map.

      This list does not include markers generated by the MapView from Placemarks.

      Returns:
      List of user created markers.
    • getAssociatedPlacemark

      @Nullable public Placemark getAssociatedPlacemark(@NonNull Marker marker)
      Return any associated Placemark for Markers generated through calls to markerForPlacemark.
      Returns:
      A Placemark used to generate this Marker.
    • isCurrentLocationMarker

      public boolean isCurrentLocationMarker(@NonNull Marker marker)
      Determines if a specified Marker is the current Location Marker.
      Returns:
      True if the Marker parameter is the current Location Marker.
    • getLocationMarker

      public LocationMarker getLocationMarker()
      Get the current Location Marker (e.g., blue dot).
      Returns:
      Returns the LocationMarker for this MapView.
    • setLocationMarker

      public void setLocationMarker(@NonNull LocationMarker marker)
      Sets the Location Marker for this MapView.

      This can be used to customize the blue dot.

      Parameters:
      marker - The new LocationMarker for this MapView.
    • setMarkers

      public void setMarkers(Collection<Marker> markers)
      Sets the Markers for this MapView.

      This will replace any previously added Markers and should be called sparingly.

      Parameters:
      markers - A collection of Markers to add to the MapView.
    • commitTransaction

      public void commitTransaction(@NonNull Transaction transaction)
      Commits a Transaction to be applied to the MapView.

      This is used to change Markers on the map.

      Parameters:
      transaction - The transaction to commit, must not be null.
    • getRoute

      public Route getRoute()
      Get the current displayed Route.
      Returns:
      displayed directions route
    • getRouteStepIndex

      public int getRouteStepIndex()
      Get the current step index.
      Returns:
      the current step in the directions route
    • setDirectionPathOptions

      public void setDirectionPathOptions(int activeStepColor, int inactiveStepColor, float thicknessRatio)
      Set the direction’s path colors and thickness.
      Parameters:
      activeStepColor - The color for the currently active path step (see: getRouteStepIndex())
      inactiveStepColor - The color for the inactive path steps
      thicknessRatio - A multiplier applied to increase or decrease path thickness (limited to 0.10 < x < 10.00)
    • showsPlacemarks

      public boolean showsPlacemarks()
      Returns if the map’s placemarks will be displayed.
      Returns:
      True if the MapView is set to show placemarks.
    • setShowsPlacemarks

      public void setShowsPlacemarks(boolean showsPlacemarks)
      Set if the MapView should show Placemarks or not.

      This must be called before the map is loaded.

      Parameters:
      showsPlacemarks - If true (the default), the map’s placemarks will be displayed.
    • showsUserLocation

      public boolean showsUserLocation()
      Returns if the user’s current location is shown on the map.
      Returns:
      True if the MapView is set to show the user’s location.
    • setShowsUserLocation

      public void setShowsUserLocation(boolean showUserLocation)
      Set if the MapView should show the user’s location or not.
      Parameters:
      showUserLocation - If true, the map will show the user’s current location when available.
    • getUserLocation

      public MeridianLocation getUserLocation()
      Get the user’s current location.
      Returns:
      The user’s current location MeridianLocation
    • getOptions

      public MapOptions getOptions()
      Gets a copy of the current options for this MapView.

      Changing the properties of the returned MapOptions will have no effect. To change the MapOptions for this MapView, call setOptions.

      Returns:
      The current map options
    • setOptions

      public void setOptions(MapOptions options)
      Set the options for this MapView.

      The properties of the options parameter are copied into the Map options of this MapView.

      Parameters:
      options - map options to apply
    • setOptions

      public void setOptions(MapOptions options, List<MapInfo> maps)
      Set the options and maps for this MapView.

      The properties of the options parameter are copied into the Map options of this MapView. Only use this method if your application is using LevelPickerControl.PickerStyle.PICKER_SEARCH and has already retrieved the maps from the server (e.g., Aruba Meridian).

      Parameters:
      options - map options to apply
      maps - all of the maps for the map picker
    • getDirectionsOptions

      public DirectionsOptions getDirectionsOptions()
      Gets a copy of the current directions options for this MapView.

      Changing the properties of the returned DirectionsOptions will have no effect. To change the DirectionsOptions for this MapView, call setDirectionsOptions.

      Returns:
      The current map directions options
    • setDirectionsOptions

      public void setDirectionsOptions(DirectionsOptions options)
      Set the directions options for this MapView.

      The properties of the options parameter are copied into the Directions options of this MapView.

      Parameters:
      options - directions options to apply
    • showLoadingCurtain

      public void showLoadingCurtain(boolean show)
      Show or hide a loading indicator for this view.
      Parameters:
      show - true to show the indicator false to hide it
    • getLevelPickerControl

      public LevelPickerControl getLevelPickerControl()
      Returns the level picker control.

      This could be used to set the selected level.

      Returns:
      The LevelPickerControl for the map
    • onTransformUpdated

      public void onTransformUpdated(Matrix transform)
      Internal handler for map changes
    • onMapChange

      public void onMapChange(MapInfo map)
      Internal map event handler
    • onCurrentLevelReselected

      public void onCurrentLevelReselected()
      Internal map event handler.

      When selecting the current map in the map picker, the map picker is dismissed and onMapClick is fired.

    • onRouteStepChange

      public void onRouteStepChange(RouteStep step)
      Internal map event handler
    • onInterceptTouchEvent

      public boolean onInterceptTouchEvent(MotionEvent ev)
      Internal handler for View’s onInterceptTouchEvent
      Overrides:
      onInterceptTouchEvent in class ViewGroup
    • onOverviewMapButtonClick

      public void onOverviewMapButtonClick()
      Internal map event handler
    • onRouteOverviewButtonClick

      public void onRouteOverviewButtonClick()
      Internal map event handler
    • onRouteResumeButtonClick

      public void onRouteResumeButtonClick()
      Internal map event handler
    • onLocationButtonClick

      public void onLocationButtonClick()
    • updateForLocation

      public void updateForLocation(@NonNull MeridianLocation location)
      Moves map focus to specified location
      Parameters:
      location - map location to focus on
    • isAccessible

      public static boolean isAccessible(Context c)
      Returns if accessible routes are being used.
      Returns:
      True if MapView is in use accessible routes mode.
    • setAccessibleRoutes

      public static void setAccessibleRoutes(Context context, boolean useAccessibleRoutes)
      Set if accessible routes should be used.
      Parameters:
      context - The application context.
      useAccessibleRoutes -
      • if accessible routes should be used.
    • onAccessibilityButtonClick

      public void onAccessibilityButtonClick()
      Internal map event handler
    • onEndButtonClick

      public void onEndButtonClick()
      Internal map event handler
    • onLocationUpdate

      public void onLocationUpdate(MeridianLocation location)
      Internal map event handler
      Specified by:
      onLocationUpdate in interface MeridianLocationManager.LocationUpdateListener
    • onLocationError

      public void onLocationError(Throwable tr)
      Called when there was an error updating the users location.
      Specified by:
      onLocationError in interface MeridianLocationManager.LocationUpdateListener
    • onEnableBluetoothRequest

      public void onEnableBluetoothRequest()
      Called when Bluetooth is currently disabled and more accurate location information could be derived with Bluetooth enabled.

      It would be appropriate to prompt the user to turn on their Bluetooth and provide and button that will launch an intent to display the Bluetooth settings if this added functionality is desired.

      Specified by:
      onEnableBluetoothRequest in interface MeridianLocationManager.LocationUpdateListener
    • onEnableWiFiRequest

      public void onEnableWiFiRequest()
      Called when WiFi is currently disabled and more accurate location information could be derived with WiFi enabled.

      It would be appropriate to prompt the user to turn on their WiFi and provide and button that will launch an intent to display the WiFi settings if this added functionality is desired.

      Specified by:
      onEnableWiFiRequest in interface MeridianLocationManager.LocationUpdateListener
    • onEnableGPSRequest

      public void onEnableGPSRequest()
      Called when GPS is currently disabled and more accurate location information could be derived with GPS enabled.

      It would be appropriate to prompt the user to turn on their GPS and provide and button that will launch an intent to display the GPS settings if this added functionality is desired.

      Specified by:
      onEnableGPSRequest in interface MeridianLocationManager.LocationUpdateListener
    • onMapParsingError

      public void onMapParsingError()
      Internal map event handler for loading errors
    • onMarkerClick

      public void onMarkerClick(Marker marker)
      Internal map event handler for when a marker is tapped.
    • onCollision

      public void onCollision(String json)
      Internal map event handler for highlighted markers.
    • onDirectionsButtonClick

      public void onDirectionsButtonClick()
      Internal map event handler that calls DirectionsEventListener.onDirectionsClick.
    • onCalloutClick

      public void onCalloutClick()
      Internal map event handler that calls MarkerEventListener.onCalloutClick.
    • onMapClick

      public void onMapClick()
      Internal map event handler that deselects the current Marker.
    • onDoubleTap

      public void onDoubleTap(float x, float y)
      Internal map event handler that zooms to the point.
    • onTwoFingerTap

      public void onTwoFingerTap(float x, float y)
      Internal map event handler that zooms out around center of screen.
    • onMapFinishedLoading

      public void onMapFinishedLoading()
      Internal map event handler that calls MapEventListener.onMapLoadFinish
    • onSkuChanged

      public void onSkuChanged(Boolean useMaps, Boolean useBlueDot, Boolean useTags)
    • getCurrentScreenToMapTransform

      public Matrix getCurrentScreenToMapTransform()
      Gets the current transformation matrix (3x3) between the screen and the map.
      Returns:
      The transformation matrix
    • onDirectionsRequestStart

      public void onDirectionsRequestStart()
      Called when beginning to request directions.
      Specified by:
      onDirectionsRequestStart in interface Directions.DirectionsRequestListener
    • onDirectionsRequestComplete

      public void onDirectionsRequestComplete(DirectionsResponse response)
      Called when the web request for directions is completed successfully.
      Specified by:
      onDirectionsRequestComplete in interface Directions.DirectionsRequestListener
    • onDirectionsRequestError

      public void onDirectionsRequestError(Throwable tr)
      Called when the request for directions encounters an error.
      Specified by:
      onDirectionsRequestError in interface Directions.DirectionsRequestListener
    • onDirectionsRequestCanceled

      public void onDirectionsRequestCanceled()
      Called when the directions request is canceled by the user.
      Specified by:
      onDirectionsRequestCanceled in interface Directions.DirectionsRequestListener
    • endDirections

      public void endDirections()
      Ends the current directions route for this MapView.

      This is the same as pressing the end directions button

    • setRoute

      public void setRoute(Route route)
      Set a directions route for this MapView.

      Do NOT use this with mapFragment. Use mapFragment’s startDirections instead.

      Parameters:
      route - The route to display.
    • setRoute

      public void setRoute(Route route, int stepIndex)
      Set a directions route and current step index for this MapView.

      Do NOT use this with mapFragment. Use mapFragment’s startDirections instead.

      Parameters:
      route - The route to display.
      stepIndex - The index of the desired step.
    • restoreRoute

      public void restoreRoute(Route route, int stepIndex)
      Restore a directions route and current step index for this MapView.
      Parameters:
      route - Route to restore.
      stepIndex - The index of the desired step.
    • setRouteStepIndex

      public void setRouteStepIndex(int index)
      Sets the step index for the current route.
      Parameters:
      index - The index of the desired step.
    • scrollToOverview

      public void scrollToOverview()
      Scroll and zoom map to include the entire loaded map.
    • scrollToRect

      public void scrollToRect(RectF target)
      Updates the currently visible portion of the map.
      Parameters:
      target - The rectangle describing the part of the map that should be visible.
    • scrollToRect

      public void scrollToRect(RectF target, boolean animated)
      Updates the currently visible portion of the map, optionally animating the change.
      Parameters:
      target - The rectangle describing the part of the map that should be visible.
      animated - If true, the change will be animated. Otherwise, the change will be instant.
    • scrollToRect

      public void scrollToRect(RectF target, float heading)
      Updates the currently visible portion and orientation of the map.
      Parameters:
      target - The rectangle describing the part of the map that should be visible.
      heading - The angle, in radians, the map’s angle will become.
    • scrollToRect

      public void scrollToRect(RectF target, float heading, boolean animated)
      Updates the currently visible portion and orientation of the map, optionally animating the change.
      Parameters:
      target - The rectangle describing the part of the map that should be visible.
      heading - The angle, in radians, the map’s angle will become.
      animated - If true, the change will be animated. Otherwise, the change will be instant.
    • rectWithCenter

      public RectF rectWithCenter(PointF centerPoint, MapInfo.ZoomLevel zoomLevel)
      Returns a rectangle centered on the specified point and sized according to the specified zoom level.
      Parameters:
      centerPoint - The point at which to place the rectangle’s center.
      zoomLevel - The zoom level to use when determining the rectangle’s size.
    • onThreeFingerLongPress

      public void onThreeFingerLongPress()
      Internal map event handler
    • onTwoFingerLongPress

      public void onTwoFingerLongPress()
      Internal map event handler
    • onOneFingerLongPress

      public void onOneFingerLongPress(float x, float y)
      Internal map event handler
    • expandPicker

      public void expandPicker()
      Expands the map picker, deselecting the currently selected Marker.
    • setBackground

      public void setBackground(Drawable background)
      Sets the background color for the map.
      Overrides:
      setBackground in class View
      Parameters:
      background - A ColorDrawable to set the background to.
    • showBannerMessage

      public void showBannerMessage(String message)
      Shows a banner message at the top of the map screen.

      The banner message is used to display relevant information in a banner (e.g., “Reorient yourself to the directions line”)

      Parameters:
      message - Message to be shown in the banner.
    • hideBannerMessage

      public void hideBannerMessage(String accessibilityMessage)
      Hides the banner message at the top of the map screen with option to provide an accessible message.
      Parameters:
      accessibilityMessage - TalkBack message to be announced. Null if no message is desired.
    • restartLocationManager

      public void restartLocationManager()
      Causes the location manager to start.

      In general this should not be called unless something changed since opening the mapview. One example would be if the user accepted additional permissions (e.g. location) while the map was open.