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

Java LatLngBounds类代码示例

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

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



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

示例1: boundCameraToRoute

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
public void boundCameraToRoute() {
  if (route != null) {
    List<Point> routeCoords = LineString.fromPolyline(route.geometry(),
      Constants.PRECISION_6).coordinates();
    List<LatLng> bboxPoints = new ArrayList<>();
    for (Point point : routeCoords) {
      bboxPoints.add(new LatLng(point.latitude(), point.longitude()));
    }
    if (bboxPoints.size() > 1) {
      try {
        LatLngBounds bounds = new LatLngBounds.Builder().includes(bboxPoints).build();
        animateCameraBbox(bounds, CAMERA_ANIMATION_DURATION, new int[] {50, 500, 50, 335});
      } catch (InvalidLatLngBoundsException exception) {
        Toast.makeText(this, "Valid route not found.", Toast.LENGTH_SHORT).show();
      }
    }
  }
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:19,代码来源:NavigationViewActivity.java


示例2: startDownloadIfNeeded

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
private void startDownloadIfNeeded(Intent intent, final List<OfflineRegion> presentOfflineRegions) {
    if (intent == null) {
        return;
    }
    final int size = intent.getIntExtra(SIZE_PARAM, -1);
    if (size != -1) {
        int c = 0;
        // There is some regions to download
        for (int i = 0; i < size; i++) {
            ArrayList<String> areasString = intent.getStringArrayListExtra(LIST_PARAM + i);
            LatLngBounds bounds = convertToLatLngBounds(areasString);
            OfflineRegion presentOfflineRegion = containsInOfflineRegion(presentOfflineRegions, bounds);
            if (presentOfflineRegion == null) {
                // The region has never been downloaded
                String regionName = intent.getStringExtra(REGION_NAME_PARAM);
                regionName = regionName == null ? "Region " + (presentOfflineRegions.size() + c)
                        : regionName;
                c++;
                downloadOfflineRegion(bounds, regionName);
            } else {
                //The region is already downloaded, we check if it was completed
                checkIfRegionDownloadIsCompleted(presentOfflineRegion);
            }
        }
    }
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:27,代码来源:OfflineRegionDownloadService.java


示例3: loadPoi

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
private void loadPoi(boolean refreshData, boolean forceRefresh) {
    if (poiTypes == null) {
        Timber.v("PleaseLoadPoiTypes");
        eventBus.post(new PleaseLoadPoiTypes());
    }


    LatLngBounds viewLatLngBounds = mapFragment.getViewLatLngBounds();
    if (viewLatLngBounds != null) {
        if (mapFragment.getZoomLevel() > BuildConfig.ZOOM_MARKER_MIN) {
            if (shouldReload(viewLatLngBounds) || refreshData || forceRefresh) {
                previousZoom = mapFragment.getZoomLevel();
                triggerReloadPoiLatLngBounds = LatLngBoundsUtils.enlarge(viewLatLngBounds, 1.2);
                LatLngBounds latLngToLoad = LatLngBoundsUtils.enlarge(viewLatLngBounds, 1.2);
                getPoisAndNotes.unsubscribe();
                Timber.e("Unsubscribe current loading");
                getPoisAndNotes.init(Box.convertFromLatLngBounds(latLngToLoad), refreshData).execute(new GetPoisSubscriber());
                mapFragment.displayZoomTooLargeError(false);
            }
        } else {
            forceRefreshPoi = true;
            cleanAllZoomTooLarge();
        }
    }
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:26,代码来源:MapFragmentPresenter.java


示例4: startSnapShot

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
/**
 * Creates bitmap from given parameters, and creates a notification with that bitmap
 *
 * @param latLngBounds of map
 * @param height       of map
 * @param width        of map
 */
private void startSnapShot(LatLngBounds latLngBounds, int height, int width) {
  if (mapSnapshotter == null) {
    // Initialize snapshotter with map dimensions and given bounds
    MapSnapshotter.Options options =
      new MapSnapshotter.Options(width, height).withStyle(mapboxMap.getStyleUrl()).withRegion(latLngBounds);

    mapSnapshotter = new MapSnapshotter(SnapshotNotificationActivity.this, options);
  } else {
    // Reuse pre-existing MapSnapshotter instance
    mapSnapshotter.setSize(width, height);
    mapSnapshotter.setRegion(latLngBounds);
  }

  mapSnapshotter.start(new MapSnapshotter.SnapshotReadyCallback() {
    @Override
    public void onSnapshotReady(MapSnapshot snapshot) {
      createNotification(snapshot.getBitmap());
    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:28,代码来源:SnapshotNotificationActivity.java


示例5: offlinePlaceStartDownload

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的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


示例6: getLatLngBounds

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
public static LatLngBounds getLatLngBounds(@NonNull Location location, double kilometers) {
    double latToKm = 110.574;
    double lonToKm = 111.320 * Math.cos(Math.toRadians(location.getLatitude()));
    double latDelta = kilometers / latToKm;
    double lonDelta = kilometers / lonToKm;
    LatLng northEast = new LatLng(location.getLatitude() + latDelta, location.getLongitude() + lonDelta);
    LatLng southWest = new LatLng(location.getLatitude() - latDelta, location.getLongitude() - lonDelta);
    return new LatLngBounds.Builder()
            .include(northEast)
            .include(southWest)
            .build();
}
 
开发者ID:Turistforeningen,项目名称:SjekkUT,代码行数:13,代码来源:Utils.java


示例7: zoomOutToFitAllMarkers

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
protected void zoomOutToFitAllMarkers() {
    try {
        if (mapboxMap != null) {
            Location mCurrentLocation = mapboxMap.getMyLocation();
            List<LatLng> lst = new ArrayList<>();
            LatLngBounds.Builder builder = new LatLngBounds.Builder();
            for (Marker marker : mapboxMap.getMarkers()) {
                lst.add(marker.getPosition());
            }

            if (mCurrentLocation != null)
                lst.add(new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude()));

            //Add current location to camera bounds
            if (lst.size() == 1)
                moveCamera(new LatLng(lst.get(0).getLatitude(), lst.get(0).getLongitude()), Constants.ZOOM_TO_SEE_FARTHER_DISTANCE);
            else if (lst.size() > 1) {
                builder.includes(lst);
                LatLngBounds bounds = builder.build();

                //If there's only 2 points in the list and the currentlocation is known, that means only one of them is a saved spot
                if (mCurrentLocation != null && lst.size() == 2)
                    mapboxMap.easeCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150), 5000);
                else
                    mapboxMap.easeCamera(CameraUpdateFactory.newLatLngBounds(bounds, 120), 5000);
            }
        }

    } catch (Exception ex) {
        Crashlytics.logException(ex);
        showErrorAlert(getResources().getString(R.string.general_error_dialog_title), String.format(getResources().getString(R.string.general_error_dialog_message),
                "Show all markers failed - " + ex.getMessage()));
    }
}
 
开发者ID:Hitchwiki,项目名称:MyHitchhikingSpots-for-Android,代码行数:35,代码来源:MyMapsActivity.java


示例8: convertFromLatLngBounds

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
/**
 * Convert a {@link com.mapbox.mapboxsdk.geometry.LatLngBounds} to a box.
 *
 * @param latLngBounds The boundingBox to convert.
 * @return The box.
 */
public static Box convertFromLatLngBounds(LatLngBounds latLngBounds) {
    Box box = new Box();
    box.setEast(latLngBounds.getLonEast());
    box.setNorth(latLngBounds.getLatNorth());
    box.setSouth(latLngBounds.getLatSouth());
    box.setWest(latLngBounds.getLonWest());
    return box;
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:15,代码来源:Box.java


示例9: enlarge

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
/**
 * Enlarge the Box.
 *
 * @param viewLatLngBounds The box to enlarge.
 * @param factor The factor to enlarge the box.
 * @return Box the Box enlarged.
 */
public static LatLngBounds enlarge(LatLngBounds viewLatLngBounds, double factor) {
    double n = viewLatLngBounds.getLatNorth();
    double e = viewLatLngBounds.getLonEast();
    double s = viewLatLngBounds.getLatSouth();
    double w = viewLatLngBounds.getLonWest();
    double f = (factor - 1) / 2;
    return new LatLngBounds.Builder()
            .include(new LatLng(n + f * (n - s), e + f * (e - w)))
            .include(new LatLng(s - f * (n - s), w - f * (e - w)))
            .build();
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:19,代码来源:Box.java


示例10: containsInOfflineRegion

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的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: convertToLatLngBounds

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
private LatLngBounds convertToLatLngBounds(List<String> latLngBoundsStrings) {
    if (latLngBoundsStrings.size() == 4) {
        return new LatLngBounds.Builder()
                .include(new LatLng(Double.parseDouble(latLngBoundsStrings.get(0)), Double.parseDouble(latLngBoundsStrings.get(1))))
                .include(new LatLng(Double.parseDouble(latLngBoundsStrings.get(2)), Double.parseDouble(latLngBoundsStrings.get(3))))
                .build();
    }
    return null;
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:10,代码来源:OfflineRegionDownloadService.java


示例12: downloadAreaForEdition

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
private void downloadAreaForEdition() {
        if (getZoomLevel() >= zoomVectorial) {
//            progressBar.setVisibility(View.VISIBLE);
            LatLngBounds viewLatLngBounds = getViewLatLngBounds();
            eventBus.post(new SyncDownloadWayEvent(viewLatLngBounds));
        } else {
            Toast.makeText(getActivity(), getString(R.string.zoom_to_edit), Toast.LENGTH_SHORT).show();
        }
    }
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:10,代码来源:MapFragment.java


示例13: enlarge

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
public static LatLngBounds enlarge(LatLngBounds viewLatLngBounds, double factor) {
    double n = viewLatLngBounds.getLatNorth();
    double e = viewLatLngBounds.getLonEast();
    double s = viewLatLngBounds.getLatSouth();
    double w = viewLatLngBounds.getLonWest();
    double f = (factor - 1) / 2;
    return new LatLngBounds.Builder()
            .include(new LatLng(n + f * (n - s), e + f * (e - w)))
            .include(new LatLng(s - f * (n - s), w - f * (e - w)))
            .build();
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:12,代码来源:LatLngBoundsUtils.java


示例14: convertDoubleList

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
public ArrayList<String> convertDoubleList(LatLngBounds bounds, boolean inversed) {
    ArrayList<String> latLngBounds = new ArrayList<>();
    if (inversed) {
        latLngBounds.add(String.valueOf(bounds.getLatSouth()));
        latLngBounds.add(String.valueOf(bounds.getLonWest()));
        latLngBounds.add(String.valueOf(bounds.getLatNorth()));
        latLngBounds.add(String.valueOf(bounds.getLonEast()));
    } else {
        latLngBounds.add(String.valueOf(bounds.getLonWest()));
        latLngBounds.add(String.valueOf(bounds.getLatSouth()));
        latLngBounds.add(String.valueOf(bounds.getLonEast()));
        latLngBounds.add(String.valueOf(bounds.getLatNorth()));
    }
    return latLngBounds;
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:16,代码来源:OfflineRegionsActivity.java


示例15: animateCameraToBounds

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
private void animateCameraToBounds(final LatLngBounds bounds) {
    mapboxMap.easeCamera(CameraUpdateFactory
            .newLatLngBounds(inverseLatLngBounds(bounds),
                    PADDING_OTHER_BOUNDS,
                    PADDING_TOP_BOUNDS,
                    PADDING_OTHER_BOUNDS,
                    PADDING_OTHER_BOUNDS), 500);
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:9,代码来源:OfflineRegionsActivity.java


示例16: shouldReload

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
private boolean shouldReload(LatLngBounds viewLatLngBounds) {
    if (forceRefreshPoi || forceRefreshNotes) {
        forceRefreshPoi = false;
        forceRefreshNotes = false;
        return true;
    }
    if (previousZoom != null && previousZoom < BuildConfig.ZOOM_MARKER_MIN) {
        return true;
    }
    return triggerReloadPoiLatLngBounds == null
            || !triggerReloadPoiLatLngBounds.union(viewLatLngBounds).equals(triggerReloadPoiLatLngBounds) || abortedTooManyPois;
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:13,代码来源:MapFragmentPresenter.java


示例17: onMapClick

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
@Override
public void onMapClick(@NonNull LatLng point) {
  LatLngBounds latLngBounds = new LatLngBounds.Builder()
    .include(locationOne) // Northeast
    .include(locationTwo) // Southwest
    .build();

  mapboxMap.easeCamera(CameraUpdateFactory.newLatLngBounds(latLngBounds, 50), 5000);
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:10,代码来源:BoundingBoxCameraActivity.java


示例18: startSnapShot

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
/**
 * Creates bitmap from given parameters, and creates a notification with that bitmap
 *
 * @param latLngBounds of map
 * @param height       of map
 * @param width        of map
 */
private void startSnapShot(LatLngBounds latLngBounds, int height, int width) {
  if (mapSnapshotter == null) {
    // Initialize snapshotter with map dimensions and given bounds
    MapSnapshotter.Options options =
      new MapSnapshotter.Options(width, height).withRegion(latLngBounds).withStyle(mapboxMap.getStyleUrl());

    mapSnapshotter = new MapSnapshotter(SnapshotShareActivity.this, options);
  } else {
    // Reuse pre-existing MapSnapshotter instance
    mapSnapshotter.setSize(width, height);
    mapSnapshotter.setRegion(latLngBounds);
    mapSnapshotter.setRegion(latLngBounds);
  }

  mapSnapshotter.start(new MapSnapshotter.SnapshotReadyCallback() {
    @Override
    public void onSnapshotReady(MapSnapshot snapshot) {

      Bitmap bitmapOfMapSnapshotImage = snapshot.getBitmap();

      Uri bmpUri = getLocalBitmapUri(bitmapOfMapSnapshotImage);

      Intent shareIntent = new Intent();
      shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
      shareIntent.setType("image/png");
      shareIntent.setAction(Intent.ACTION_SEND);
      shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
      startActivity(Intent.createChooser(shareIntent, "Share map image"));

      hasStartedSnapshotGeneration = false;
    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:41,代码来源:SnapshotShareActivity.java


示例19: animateCameraBbox

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的package包/类
private void animateCameraBbox(LatLngBounds bounds, int animationTime, int[] padding) {
  mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds,
    padding[0], padding[1], padding[2], padding[3]), animationTime);
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:5,代码来源:NavigationViewActivity.java


示例20: onDownloadRegion

import com.mapbox.mapboxsdk.geometry.LatLngBounds; //导入依赖的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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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