Package globus.glmap

Class GLMapManager

java.lang.Object
globus.glmap.GLMapManager

@ParametersAreNonnullByDefault
public class GLMapManager
extends java.lang.Object
GLMapManager is a singleton object that manages offline maps
  • Constructor Details

  • Method Details

    • Initialize

      public static boolean Initialize​(android.content.Context context, java.lang.String apiKey, @Nullable ProgressCallback progressCallback)
      Initializes GLMapManager

      During first initialization it copies world map file from app resources to cache directory. Framework uses progressCallback to notify about initialization(copying) progress

      Parameters:
      context - Application context
      apiKey - API key of this application
      progressCallback - initialization progress callback
      Returns:
      true if initialized successfully
    • SetStorages

      public static boolean SetStorages​(android.content.Context context, @Nullable java.lang.Object writeStorage, @Nullable java.util.Set<java.lang.Object> customStorages)
      Sets location of caches before initialization. By default caches are set to getFilesDir() of context passed to initialize function, or getExternalFilesDir(null) if external storage is mounted.
      Parameters:
      context - the Context used to find default map locations
      writeStorage - location to write maps (can be String, or CustomMapStorage)
      customStorages - Array of custom storages to read maps (write path will be automatically added)
      Returns:
      Returns true on success
    • UpdateMapList

      public static void UpdateMapList​(@Nullable GLMapManager.MapListUpdateCallback complete)
      Updates map list from server
      Parameters:
      complete - runnable, called when map update is complete
    • DownloadURL

      public static long DownloadURL​(java.lang.String url, long timestamp, GLMapManager.DownloadURLCallback complete)
    • CancelDownloadURL

      public static void CancelDownloadURL​(long id)
    • DownloadDataSet

      @NonNull public static GLMapDownloadTask DownloadDataSet​(GLMapInfo mapInfo, int dataSet)
      Creates map downloading tasks
      Parameters:
      mapInfo - map info object
      dataSet - data set to download
      Returns:
      download task
    • DownloadDataSets

      @NonNull public static java.util.List<GLMapDownloadTask> DownloadDataSets​(GLMapInfo mapInfo, int dataSets)
      Creates map downloading tasks
      Parameters:
      mapInfo - map info object
      dataSets - data sets to download
      Returns:
      download task
    • DeleteDataSets

      public static void DeleteDataSets​(GLMapInfo info, int dataSets)
      Delete data sets associated with this map.
      Parameters:
      info - map to delete
      dataSets - data sets to delete
    • removeStateListener

      public static void removeStateListener​(GLMapManager.StateListener val)
      /** Removes listener added by addStateListener
      Parameters:
      val - Listener to remove
      See Also:
      addStateListener(StateListener)
    • addStateListener

      public static void addStateListener​(GLMapManager.StateListener listener)
      Subscribes listener to events about map downloading progress.

      Event name is sent via fieldName
      finished 0 at start, 1 at end of task
      progressDownload sent each time when download progress is changed.

      
       task.addListener(new FieldListener(){
              public void fieldValueChanged(Object obj, String fieldName, Object newValue){
                      ((MapsAdapter)listView.getAdapter()).notifyDataSetChanged();
          }
       });
       
      Parameters:
      listener - that will receive events
      See Also:
      removeStateListener(StateListener)
    • postOnMain

      public static void postOnMain​(java.lang.Runnable runnable)
    • getMapDownloadTasks

      @NonNull public static java.util.List<GLMapDownloadTask> getMapDownloadTasks()
      Returns:
      Returns the list of created and not finished map download tasks
    • getDownloadTasks

      @Nullable public static java.util.List<GLMapDownloadTask> getDownloadTasks​(long mapID, int dataSets)
      Returns download tasks for maps
      Parameters:
      mapID - Id of map
      dataSets - data sets of download tasks
      Returns:
      Returns download task for map
    • getDownloadTask

      @Nullable public static GLMapDownloadTask getDownloadTask​(long mapID, int dataSet)
      Returns download tasks for maps
      Parameters:
      mapID - Id of map
      dataSet - data set of download task
      Returns:
      Returns download task for map
    • GetChildMaps

      @NonNull public static GLMapInfo[] GetChildMaps()
      Return array of maps including submaps
      Returns:
      Returns array of maps including submaps
    • GetMaps

      @NonNull public static GLMapInfo[] GetMaps()
      Returns:
      Returns array of maps
    • GetMapWithID

      @Nullable public static GLMapInfo GetMapWithID​(long mapID)
      Parameters:
      mapID - MapId of map
      Returns:
      Returns GLMapInfo for given mapID
    • AddMap

      public static boolean AddMap​(android.content.res.AssetManager mng, java.lang.String assetFileName, @Nullable ProgressCallback progressCallback)
      Adds vector map. Could be used for maps embed into the app resources.
      Parameters:
      mng - AssetManager where custom map is located
      assetFileName - name of custom map
      progressCallback - callback to track progress of custom map caching
      Returns:
      true if success
    • RemoveMap

      public static void RemoveMap​(java.lang.String fileName)
      Removes vector map from map manager. When removed it is safe to delete cached map file.
      Parameters:
      fileName - name of custom map
    • MapsAtPoint

      @Nullable public static GLMapInfo[] MapsAtPoint​(MapPoint point)
      Returns mapID of vector map that contains given point. If there is no maps that contain given point null is returned.
      Parameters:
      point - point that vector map must contain
      Returns:
      mapID of vector map or null
    • FindNearestMap

      @NonNull public static GLMapInfo FindNearestMap​(GLMapInfo[] maps, MapPoint point)
      Helper function iterates over maps param and returns closest GLMapInfo to the given point.
      Parameters:
      maps - array of map objects
      point - point that vector map must contain
      Returns:
      mapID of vector map
    • DistanceToMap

      public static double DistanceToMap​(GLMapInfo map, MapPoint point)
      Calculates distance from the map to the point
      Parameters:
      map - map object
      point - some point
      Returns:
      Measured distance in internal units
    • SortMaps

      public static void SortMaps​(GLMapInfo[] maps, MapPoint point)
      Sorts array of GLMapInfo by distance from given point
      Parameters:
      maps - array of map objects
      point - center from where distance is calculated
    • SetTileDownloadingAllowed

      public static void SetTileDownloadingAllowed​(boolean val)
      Allows GLMapManager to download single tiles when downloaded vector maps does not contain data.
      Parameters:
      val - true to enable tile downloading
    • GetTileDownloadingAllowed

      public static boolean GetTileDownloadingAllowed()
      Returns:
      true if tile downloading allowed
    • VectorTilesAtBBox

      public static long[] VectorTilesAtBBox​(GLMapBBox bbox)
      Returns vector tiles that bbox contains or intersects
      Parameters:
      bbox - bbox of area
      Returns:
      vector tiles that bbox contains or intersects
    • NotCachedVectorTilesAtBBox

      public static long[] NotCachedVectorTilesAtBBox​(GLMapBBox bbox)
      Returns not cached vector tiles that bbox contains or intersects
      Parameters:
      bbox - bbox of area
      Returns:
      not cached vector tiles that bbox contains or intersects
    • CacheTiles

      public static void CacheTiles​(long[] tiles, GLMapManager.TileDownloadProgress progress)
      Check if tiles are cached. If not - tile will be downloaded.
      Parameters:
      tiles - tiles to check
      progress - callbacks that will be called when one tile is checked.
    • SetDownloadStatsCallback

      public static void SetDownloadStatsCallback​(GLMapManager.DownloadStatsCallback callback)
      Callback will be called when subtask is completed or cancelled. It's used to analyze downloading speeds from different locations.
      Parameters:
      callback - callback to call when new stats available
    • GetDownloadedMapsCount

      public static int GetDownloadedMapsCount()
      Returns:
      Returns number of the maps that have any downloaded data