@ParametersAreNonnullByDefault
public class GLMapManager
extends java.lang.Object
GLMapManager is a singleton object that manages offline maps| Modifier and Type | Class and Description |
|---|---|
static interface |
GLMapManager.DownloadStatsCallback |
static interface |
GLMapManager.MapListUpdateCallback |
static interface |
GLMapManager.StateListener |
static interface |
GLMapManager.TileDownloadProgress |
| Constructor and Description |
|---|
GLMapManager() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
AddMap(android.content.res.AssetManager mng,
java.lang.String assetFileName,
ProgressCallback progressCallback)
Adds vector map.
|
static void |
addStateListener(GLMapManager.StateListener listener)
Subscribes listener to events about map downloading progress.
|
static void |
CacheTiles(long[] tiles,
GLMapManager.TileDownloadProgress progress)
Check if tiles are cached.
|
static void |
DeleteDataSets(GLMapInfo info,
int dataSets)
Delete data sets associated with this map.
|
static double |
DistanceToMap(GLMapInfo map,
MapPoint point)
Calculates distance from the map to the point
|
static GLMapDownloadTask |
DownloadDataSets(GLMapInfo mapInfo,
int dataSets,
android.content.Context context)
Creates map downloading task
|
static GLMapDownloadTask |
DownloadDataSets(GLMapInfo mapInfo,
int dataSets,
java.io.File downloadDir)
Creates map downloading task
|
static GLMapInfo |
FindNearestMap(GLMapInfo[] maps,
MapPoint point)
Helper function iterates over maps param and returns closest
GLMapInfo to the given point. |
static GLMapInfo[] |
GetChildMaps()
Return array of maps including submaps
|
static int |
GetDownloadedMapsCount() |
static GLMapDownloadTask |
getDownloadTask(GLMapInfo mapInfo)
Returns download task for map
|
static java.util.List<GLMapDownloadTask> |
getMapDownloadTasks() |
static GLMapInfo[] |
GetMaps() |
static GLMapInfo |
GetMapWithID(long mapID) |
static boolean |
GetTileDownloadingAllowed() |
static boolean |
Initialize(android.content.Context context,
java.lang.String apiKey,
ProgressCallback progressCallback)
Initializes GLMapManager
|
static GLMapInfo |
MapAtPoint(MapPoint point)
Returns mapID of vector map that contains given point.
|
static long[] |
NotCachedVectorTilesAtBBox(GLMapBBox bbox)
Returns not cached vector tiles that bbox contains or intersects
|
static void |
postOnMain(java.lang.Runnable runnable) |
static boolean |
ReloadCachedMapList(android.content.Context context)
Reload map list from cache.
|
static void |
RemoveMap(java.lang.String fileName)
Removes vector map from map manager.
|
static void |
removeStateListener(GLMapManager.StateListener val)
/**
Removes listener added by
addStateListener |
static void |
SetCachesDir(java.lang.String val)
Sets location of caches before initialization.
|
static void |
SetDownloadStatsCallback(GLMapManager.DownloadStatsCallback callback)
Callback will be called when subtask is completed or cancelled.
|
static void |
SetTileDownloadingAllowed(boolean val)
Allows
GLMapManager to download single tiles when downloaded vector maps does not contain data. |
static void |
SortMaps(GLMapInfo[] maps,
MapPoint point)
Sorts array of
GLMapInfo by distance from given point |
static void |
updateDownloadedMaps(android.content.Context context,
java.util.List<java.io.File> customDirs)
Updates location of downloaded maps from default locations and optionally given directories
|
static void |
UpdateMapList(GLMapManager.MapListUpdateCallback complete)
Updates map list from server
|
static long[] |
VectorTilesAtBBox(GLMapBBox bbox)
Returns vector tiles that bbox contains or intersects
|
public static boolean Initialize(android.content.Context context,
java.lang.String apiKey,
@Nullable
ProgressCallback progressCallback)
During first initialization it copies world map file from app resources to cache directory. Framework uses progressCallback to notify about initialization(copying) progress
context - Application contextapiKey - API key of this applicationprogressCallback - initialization progress callbackpublic static void SetCachesDir(java.lang.String val)
val - location of caches dirpublic static boolean ReloadCachedMapList(android.content.Context context)
context - contextpublic static void UpdateMapList(@Nullable
GLMapManager.MapListUpdateCallback complete)
complete - runnable, called when map update is completepublic static void updateDownloadedMaps(android.content.Context context,
java.util.List<java.io.File> customDirs)
context - the Context used to find default map locationscustomDirs - Array of custom paths of maps@NonNull public static GLMapDownloadTask DownloadDataSets(GLMapInfo mapInfo, int dataSets, java.io.File downloadDir)
mapInfo - map info objectdataSets - data sets to downloaddownloadDir - directory where map will be saved@NonNull public static GLMapDownloadTask DownloadDataSets(GLMapInfo mapInfo, int dataSets, android.content.Context context)
mapInfo - map info objectcontext - the Context used to find place where map will be saveddataSets - Data sets to download. It could be Map, Navigation or Allpublic static void DeleteDataSets(GLMapInfo info, int dataSets)
info - map to deletedataSets - data sets to deletepublic static void removeStateListener(GLMapManager.StateListener val)
addStateListenerval - Listener to removeaddStateListener(StateListener)public static void addStateListener(GLMapManager.StateListener listener)
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();
}
});
listener - that will receive eventsremoveStateListener(StateListener)public static void postOnMain(java.lang.Runnable runnable)
@NonNull public static java.util.List<GLMapDownloadTask> getMapDownloadTasks()
@Nullable public static GLMapDownloadTask getDownloadTask(GLMapInfo mapInfo)
mapInfo - Info of map@NonNull public static GLMapInfo[] GetChildMaps()
@NonNull public static GLMapInfo[] GetMaps()
@Nullable public static GLMapInfo GetMapWithID(long mapID)
mapID - MapId of mappublic static boolean AddMap(android.content.res.AssetManager mng,
java.lang.String assetFileName,
@Nullable
ProgressCallback progressCallback)
mng - AssetManager where custom map is locatedassetFileName - name of custom mapprogressCallback - callback to track progress of custom map cachingpublic static void RemoveMap(java.lang.String fileName)
fileName - name of custom map@Nullable public static GLMapInfo MapAtPoint(MapPoint point)
point - point that vector map must contain@NonNull public static GLMapInfo FindNearestMap(GLMapInfo[] maps, MapPoint point)
GLMapInfo to the given point.maps - array of map objectspoint - point that vector map must containpublic static double DistanceToMap(GLMapInfo map, MapPoint point)
map - map objectpoint - some pointpublic static void SortMaps(GLMapInfo[] maps, MapPoint point)
GLMapInfo by distance from given pointmaps - array of map objectspoint - center from where distance is calculatedpublic static void SetTileDownloadingAllowed(boolean val)
GLMapManager to download single tiles when downloaded vector maps does not contain data.val - true to enable tile downloadingpublic static boolean GetTileDownloadingAllowed()
public static long[] VectorTilesAtBBox(GLMapBBox bbox)
bbox - bbox of areapublic static long[] NotCachedVectorTilesAtBBox(GLMapBBox bbox)
bbox - bbox of areapublic static void CacheTiles(long[] tiles,
GLMapManager.TileDownloadProgress progress)
tiles - tiles to checkprogress - callbacks that will be called when one tile is checked.public static void SetDownloadStatsCallback(GLMapManager.DownloadStatsCallback callback)
callback - callback to call when new stats availablepublic static int GetDownloadedMapsCount()
Copyright © 2019 GetYourMap. All Rights Reserved.