Here-api offline maps installation

早过忘川 提交于 2019-11-28 14:23:15

You should use the MapLoader#getMapPackages() API to retrieve the root MapPackage object. You can then use the MapPackage#getId() method to find the Id's of the countries/regions you wish to install. Note that the MapPackage object is not returned directly from the MapLoader#getMapPackages() call, but instead through a Listener object. You must provide your own MapLoader.Listener implementation and set it by way of the MapLoader#addListener(MapLoader.Listener listener) method before calling getMapPackages().

For Example:

MapLoader.Listener mapLoaderListener = new MapLoader.Listener() {
  public void onUninstallMapPackagesComplete(MapPackage rootMapPackage,
     MapLoader.ResultCode mapLoaderResultCode) {
  }
  public void onProgress(int progressPercentage) {
  }
  public void onPerformMapDataUpdateComplete(MapPackage rootMapPackage,
     MapLoader.ResultCode mapLoaderResultCode) {
  }
  public void onInstallationSize(long diskSize, long networkSize) {
  }
  public void onInstallMapPackagesComplete(MapPackage rootMapPackage,
      MapLoader.ResultCode mapLoaderResultCode) {
  }
  public void onGetMapPackagesComplete(MapPackage rootMapPackage,
      MapLoader.ResultCode mapLoaderResultCode) {

      // This method will be called after MapLoader#getMapPackages()
      // is called
      // You can use the rootMapPackage object to find the Id's to
      // pass to installMapPackages()

  }
  public void onCheckForUpdateComplete(boolean updateAvailable,
    String currentMapVersion,String newestMapVersion,
          MapLoader.ResultCode mapLoaderResultCode) {
  }
};

MapLoader mapLoader = MapLoader.getInstance();

mapLoader.addListener(mapLoaderListener);
mapLoader.getMapPackages();

Further details here:

  • Developer Guide

https://developer.here.com/mobile-sdks/documentation/android-hybrid-plus/topics/maps-offline.html

  • API Reference

https://developer.here.com/mobile-sdks/documentation/android-hybrid-plus/topics_api_nlp_hybrid_plus/com-here-android-mpa-odml-maploader.html

https://developer.here.com/mobile-sdks/documentation/android-hybrid-plus/topics_api_nlp_hybrid_plus/com-here-android-mpa-odml-maploader-listener.html

https://developer.here.com/mobile-sdks/documentation/android-hybrid-plus/topics_api_nlp_hybrid_plus/com-here-android-mpa-odml-mappackage.html

You should be able to get the List using the getMapPackages() method. Documentation link : https://developer.here.com/mobile-sdks/documentation/android-hybrid-plus/topics/maps-offline.html

The only way (I think), is to recursively call getChildren() on MapPackage, then check getTitle() for each of the children package to find the region you need.

For example, to get the id of the "Bretagne" region in france, you need to go through rootMapPackage.getChildren().get(2/Europe/).getChildren().get(1/France/).getChildren().get(3/Bretagne/).getId()

Not very convenient. A method "search(String title)" on the root package would be handy.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!