当前位置: 首页>>代码示例>>Java>>正文


Java LatLngBounds类代码示例

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


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


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