• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OfflineTilePyramidRegionDefinition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition的典型用法代码示例。如果您正苦于以下问题:Java OfflineTilePyramidRegionDefinition类的具体用法?Java OfflineTilePyramidRegionDefinition怎么用?Java OfflineTilePyramidRegionDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OfflineTilePyramidRegionDefinition类属于com.mapbox.mapboxsdk.offline包,在下文中一共展示了OfflineTilePyramidRegionDefinition类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createDownload

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
private void createDownload(final OfflineDownload offlineDownload) {
  final OfflineTilePyramidRegionDefinition definition = offlineDownload.getRegionDefinition();
  final byte[] metadata = offlineDownload.getMetadata();
  OfflineManager.getInstance(getApplicationContext())
    .createOfflineRegion(
      definition,
      metadata,
      new OfflineManager.CreateOfflineRegionCallback() {
        @Override
        public void onCreate(OfflineRegion offlineRegion) {
          offlineDownload.setRegionId(offlineRegion.getID());
          OfflineDownloadStateReceiver.dispatchStartBroadcast(getApplicationContext(), offlineDownload);
          regionLongSparseArray.put(offlineDownload.getServiceId(), offlineRegion);

          launchDownload(offlineDownload, offlineRegion);
          showNotification(offlineDownload);
        }

        @Override
        public void onError(String error) {
          OfflineDownloadStateReceiver.dispatchErrorBroadcast(getApplicationContext(), offlineDownload, error);
        }
      });
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:25,代码来源:OfflineDownloadService.java


示例2: getView

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
  ViewHolder holder;

  if (convertView == null) {
    holder = new ViewHolder();
    convertView = LayoutInflater.from(context).inflate(R.layout.item_feature, parent, false);
    holder.text = convertView.findViewById(R.id.nameView);
    holder.subText = convertView.findViewById(R.id.descriptionView);
    convertView.setTag(holder);
  } else {
    holder = (ViewHolder) convertView.getTag();
  }

  currentRegion = getItem(position);
  holder.text.setText(OfflineUtils.convertRegionName(currentRegion.getMetadata()));
  holder.subText.setText(((OfflineTilePyramidRegionDefinition) currentRegion.getDefinition()).getStyleURL());
  return convertView;
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:20,代码来源:OfflineRegionListActivity.java


示例3: loadOfflineRegion

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
private void loadOfflineRegion(final long id) {
  OfflineManager.getInstance(this)
    .listOfflineRegions(new OfflineManager.ListOfflineRegionsCallback() {

      @Override
      public void onList(OfflineRegion[] offlineRegions) {
        for (OfflineRegion region : offlineRegions) {
          if (region.getID() == id) {
            offlineRegion = region;
            OfflineTilePyramidRegionDefinition definition =
              (OfflineTilePyramidRegionDefinition) region.getDefinition();
            setupUI(definition);
            return;
          }
        }
      }

      @Override
      public void onError(String error) {
        Timber.e(error);
      }
    });
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:24,代码来源:OfflineRegionDetailActivity.java


示例4: selectOfflineRegion

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
private void selectOfflineRegion(int position) {
    if (selectedRegionItem != null) {
        selectedRegionItem.setSelected(false);
    }
    selectedRegionItem = adapter.getOfflineRegion(position);
    selectedRegionItem.setSelected(true);
    OfflineTilePyramidRegionDefinition definition =
            (OfflineTilePyramidRegionDefinition) selectedRegionItem
                    .getOfflineRegion()
                    .getDefinition();
    animateCameraToBounds(definition.getBounds());
    if (selectedRegionItem.getStatus().isComplete()) {
        switchMode(Mode.STATUS_COMPLETE);
    } else {
        switchMode(Mode.STATUS_INCOMPLETE);
    }
    closeEditMenu();
    adapter.notifyDataSetChanged();
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:20,代码来源:OfflineRegionsActivity.java


示例5: equals

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
@Override
public boolean equals(Object o) {
    if (this == o) {
        return true;
    }
    if (!(o instanceof OfflineRegionItem)) {
        return false;
    }

    OfflineRegionItem that = (OfflineRegionItem) o;

    if (that.offlineRegion == null || offlineRegion == null) {
        return false;
    }

    OfflineTilePyramidRegionDefinition thatDefinition =
            (OfflineTilePyramidRegionDefinition) that.offlineRegion.getDefinition();

    OfflineTilePyramidRegionDefinition definition =
            (OfflineTilePyramidRegionDefinition) offlineRegion.getDefinition();

    return thatDefinition.getBounds().equals(definition.getBounds()) ||
            (offlineRegion != null ? offlineRegion.equals(that.offlineRegion) : that.offlineRegion == null);
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:25,代码来源:OfflineRegionItem.java


示例6: OfflineDownload

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
private OfflineDownload(Parcel in) {
  definition = in.readParcelable(OfflineTilePyramidRegionDefinition.class.getClassLoader());
  serviceId = in.readInt();
  regionId = in.readLong();
  notificationOptions = in.readParcelable(NotificationOptions.class.getClassLoader());
  progress = in.readInt();
  metadata = new byte[in.readInt()];
  in.readByteArray(metadata);
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:10,代码来源:OfflineDownload.java


示例7: createMapSnapshot

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
private void createMapSnapshot(OfflineTilePyramidRegionDefinition definition,
                               MapSnapshotter.SnapshotReadyCallback callback) {
  Resources resources = getResources();
  int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height);
  int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width);

  MapSnapshotter.Options options = new MapSnapshotter.Options(width, height);
  options.withStyle(definition.getStyleURL());
  options.withRegion(definition.getBounds());
  mapSnapshotter = new MapSnapshotter(this, options);
  mapSnapshotter.start(callback);
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:13,代码来源:OfflineDownloadService.java


示例8: setupUI

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
private void setupUI(final OfflineTilePyramidRegionDefinition definition) {
  // update map
  mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {
      // correct style
      mapboxMap.setStyle(definition.getStyleURL());

      // position map on top of offline region
      CameraPosition cameraPosition = OfflineUtils.getCameraPosition(definition);
      mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

      // restrict camera movement
      mapboxMap.setMinZoomPreference(definition.getMinZoom());
      mapboxMap.setMaxZoomPreference(definition.getMaxZoom());
      mapboxMap.setLatLngBoundsForCameraTarget(definition.getBounds());
    }
  });

  // update textview data
  nameView.setText(OfflineUtils.convertRegionName(offlineRegion.getMetadata()));
  styleView.setText(definition.getStyleURL());
  latLngBoundsView.setText(definition.getBounds().toString());
  minZoomView.setText(String.valueOf(definition.getMinZoom()));
  maxZoomView.setText(String.valueOf(definition.getMaxZoom()));
  offlineRegion.getStatus(offlineRegionStatusCallback);
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:28,代码来源:OfflineRegionDetailActivity.java


示例9: offlinePlaceStartDownload

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
private static void offlinePlaceStartDownload(final Place place) {
    final Context context = SjekkUTApplication.getContext();

    // Set up the OfflineManager
    OfflineManager offlineManager = OfflineManager.getInstance(context.getApplicationContext());

    // Create a bounding box for the offline region
    LatLngBounds latLngBounds = Utils.getLatLngBounds(place.getLocation(), MAP_OFFLINE_RADIUS);

    // Define the offline region
    OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
            context.getString(R.string.mapbox_style),
            latLngBounds,
            MAP_OFFLINE_MINZOOM,
            MAP_OFFLINE_MAXZOOM,
            context.getResources().getDisplayMetrics().density);

    byte[] metaData = GsonSingleton.gson().toJson(new OfflineRegionMetadata(place)).getBytes(Charset.defaultCharset());

    // Create the region asynchronously
    offlineManager.createOfflineRegion(definition, metaData, new OfflineManager.CreateOfflineRegionCallback() {
        @Override
        public void onCreate(OfflineRegion offlineRegion) {
            sOfflineRegionExecutor.schedule(new OfflineRegionTask(place, offlineRegion), OFFLINE_REGIONTASK_DELAY, TimeUnit.SECONDS);
        }

        @Override
        public void onError(String error) {
            Timber.e("Error: %s", error);
        }
    });
}
 
开发者ID:Turistforeningen,项目名称:SjekkUT,代码行数:33,代码来源:OfflineHelper.java


示例10: containsInOfflineRegion

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
/**
 * Check if a region is present in the list with the bounds parameter.
 * @param regions
 * @param bounds
 * @return the OfflineRegion if it's present or null.
 */
private OfflineRegion containsInOfflineRegion(List<OfflineRegion> regions, LatLngBounds bounds) {
    for (OfflineRegion offlineRegion : regions) {
        if (((OfflineTilePyramidRegionDefinition) offlineRegion.getDefinition()).getBounds().equals(bounds)) {
            return offlineRegion;
        }
    }
    return null;
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:15,代码来源:OfflineRegionDownloadService.java


示例11: getCameraPosition

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
public static CameraPosition getCameraPosition(OfflineTilePyramidRegionDefinition definition) {
  return new CameraPosition.Builder()
    .target(definition.getBounds().getCenter())
    .zoom(definition.getMinZoom())
    .build();
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:7,代码来源:OfflineUtils.java


示例12: withDefinition

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
public OfflineDownloadOptions withDefinition(OfflineTilePyramidRegionDefinition definition) {
  this.definition = definition;
  return this;
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:5,代码来源:OfflineDownloadOptions.java


示例13: getRegionDefinition

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
OfflineTilePyramidRegionDefinition getRegionDefinition() {
  return definition;
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:4,代码来源:OfflineDownload.java


示例14: onDownloadRegion

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
@OnClick(R.id.fab)
public void onDownloadRegion() {
  // get data from UI
  String regionName = regionNameView.getText().toString();
  double latitudeNorth = Double.parseDouble(latNorthView.getText().toString());
  double longitudeEast = Double.parseDouble(lonEastView.getText().toString());
  double latitudeSouth = Double.parseDouble(latSouthView.getText().toString());
  double longitudeWest = Double.parseDouble(lonWestView.getText().toString());
  String styleUrl = (String) styleUrlView.getSelectedItem();
  float maxZoom = maxZoomView.getProgress();
  float minZoom = minZoomView.getProgress();

  if (!validCoordinates(latitudeNorth, longitudeEast, latitudeSouth, longitudeWest)) {
    Toast.makeText(this, "coordinates need to be in valid range", Toast.LENGTH_LONG).show();
    return;
  }

  // create offline definition from data
  OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
    styleUrl,
    new LatLngBounds.Builder()
      .include(new LatLng(latitudeNorth, longitudeEast))
      .include(new LatLng(latitudeSouth, longitudeWest))
      .build(),
    minZoom,
    maxZoom,
    getResources().getDisplayMetrics().density
  );

  // customise notification appearance
  NotificationOptions notificationOptions = new NotificationOptions()
    .withSmallIconRes(R.drawable.mapbox_logo_icon)
    .withReturnActivity(OfflineRegionDetailActivity.class.getName());

  // start offline download
  OfflinePlugin.getInstance().startDownload(this,
    new OfflineDownloadOptions()
      .withDefinition(definition)
      .withMetadata(OfflineUtils.convertRegionName(regionName))
      .withNotificationOptions(notificationOptions)
  );
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:43,代码来源:OfflineDownloadActivity.java


示例15: downloadRegion

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
private void downloadRegion(final String regionName) {
    // Define offline region parameters, including bounds,
    // min/max zoom, and metadata

    //Create a record to track usage of Download Map Region
    Answers.getInstance().logCustom(new CustomEvent("Offline Map download click"));

    // Start the progressBar
    startProgress();

    // Create offline definition using the current
    // style and boundaries of visible map area
    String styleUrl = mapboxMap.getStyleUrl();
    LatLngBounds bounds = mapboxMap.getProjection().getVisibleRegion().latLngBounds;
    double minZoom = mapboxMap.getCameraPosition().zoom;
    double maxZoom = mapboxMap.getMaxZoomLevel();
    float pixelRatio = this.getResources().getDisplayMetrics().density;
    OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
            styleUrl, bounds, minZoom, maxZoom, pixelRatio);

    // Build a JSONObject using the user-defined offline region title,
    // convert it into string, and use it to create a metadata variable.
    // The metadata variable will later be passed to createOfflineRegion()
    byte[] metadata;
    try {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put(JSON_FIELD_REGION_NAME, regionName);
        String json = jsonObject.toString();
        metadata = json.getBytes(JSON_CHARSET);
    } catch (Exception exception) {
        Crashlytics.log("Failed to encode metadata.");
        Crashlytics.logException(exception);
        metadata = null;
    }

    // Create the offline region and launch the download
    offlineManager.createOfflineRegion(definition, metadata, new OfflineManager.CreateOfflineRegionCallback() {
        @Override
        public void onCreate(OfflineRegion offlineRegion) {
            Crashlytics.log("Offline region created: " + regionName);
            OfflineManagerActivity.this.offlineRegion = offlineRegion;
            launchDownload();
        }

        @Override
        public void onError(String error) {
            Crashlytics.logException(new Exception("Error: " + error));
        }
    });
}
 
开发者ID:Hitchwiki,项目名称:MyHitchhikingSpots-for-Android,代码行数:51,代码来源:OfflineManagerActivity.java


示例16: convertDoubleList

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
public ArrayList<String> convertDoubleList(OfflineRegion region, boolean inversed) {
    OfflineTilePyramidRegionDefinition definition = (OfflineTilePyramidRegionDefinition) region.getDefinition();
    return convertDoubleList(definition.getBounds(), inversed);
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:5,代码来源:OfflineRegionsActivity.java


示例17: downloadRegion

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
private void downloadRegion(final String regionName) {
  // Define offline region parameters, including bounds,
  // min/max zoom, and metadata

  // Start the progressBar
  startProgress();

  // Create offline definition using the current
  // style and boundaries of visible map area
  String styleUrl = map.getStyleUrl();
  LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
  double minZoom = map.getCameraPosition().zoom;
  double maxZoom = map.getMaxZoomLevel();
  float pixelRatio = this.getResources().getDisplayMetrics().density;
  OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
    styleUrl, bounds, minZoom, maxZoom, pixelRatio);

  // Build a JSONObject using the user-defined offline region title,
  // convert it into string, and use it to create a metadata variable.
  // The metadata varaible will later be passed to createOfflineRegion()
  byte[] metadata;
  try {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put(JSON_FIELD_REGION_NAME, regionName);
    String json = jsonObject.toString();
    metadata = json.getBytes(JSON_CHARSET);
  } catch (Exception exception) {
    Log.e(TAG, "Failed to encode metadata: " + exception.getMessage());
    metadata = null;
  }

  // Create the offline region and launch the download
  offlineManager.createOfflineRegion(definition, metadata, new OfflineManager.CreateOfflineRegionCallback() {
    @Override
    public void onCreate(OfflineRegion offlineRegion) {
      Log.d(TAG, "Offline region created: " + regionName);
      offlineRegionDownloaded = offlineRegion;
      launchDownload();
    }

    @Override
    public void onError(String error) {
      Log.e(TAG, "Error: " + error);
    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:47,代码来源:OfflineMapActivity.java


示例18: downloadRegion

import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; //导入依赖的package包/类
private void downloadRegion(final String regionName) {
  // Define offline region parameters, including bounds,
  // min/max zoom, and metadata

  // Start the progressBar
  startProgress();

  // Create offline definition using the current
  // style and boundaries of visible map area
  String styleUrl = map.getStyleUrl();
  LatLngBounds bounds = map.getProjection().getVisibleRegion().latLngBounds;
  double minZoom = map.getCameraPosition().zoom;
  double maxZoom = map.getMaxZoomLevel();
  float pixelRatio = this.getResources().getDisplayMetrics().density;
  OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(
    styleUrl, bounds, minZoom, maxZoom, pixelRatio);

  // Build a JSONObject using the user-defined offline region title,
  // convert it into string, and use it to create a metadata variable.
  // The metadata variable will later be passed to createOfflineRegion()
  byte[] metadata;
  try {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put(JSON_FIELD_REGION_NAME, regionName);
    String json = jsonObject.toString();
    metadata = json.getBytes(JSON_CHARSET);
  } catch (Exception exception) {
    Log.e(TAG, "Failed to encode metadata: " + exception.getMessage());
    metadata = null;
  }

  // Create the offline region and launch the download
  offlineManager.createOfflineRegion(definition, metadata, new OfflineManager.CreateOfflineRegionCallback() {
    @Override
    public void onCreate(OfflineRegion offlineRegion) {
      Log.d(TAG, "Offline region created: " + regionName);
      OfflineManagerActivity.this.offlineRegion = offlineRegion;
      launchDownload();
    }

    @Override
    public void onError(String error) {
      Log.e(TAG, "Error: " + error);
    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:47,代码来源:OfflineManagerActivity.java



注:本文中的com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ReflectAnnotationReader类代码示例发布时间:2022-05-22
下一篇:
Java Trace类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap