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


Java LatLngBounds类代码示例

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


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

示例1: zoomToPolyline

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
public static void zoomToPolyline(GoogleMap map, Polyline p) {
    if (p == null || p.getPoints().isEmpty())
        return;

    LatLngBounds.Builder builder = LatLngBounds.builder();

    for (LatLng latLng : p.getPoints()) {
        builder.include(latLng);
    }
    final LatLngBounds bounds = builder.build();

    try{
    map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));
    } catch (Exception e){
        e.printStackTrace();
    }
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:18,代码来源:MapUtils.java

示例2: getVisibleRegion

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
/**
 * Return the visible region of the map
 * Thanks @fschmidt
 */
@SuppressWarnings("unused")
private void getVisibleRegion(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
  VisibleRegion visibleRegion = map.getProjection().getVisibleRegion();
  LatLngBounds latLngBounds = visibleRegion.latLngBounds;
  JSONObject result = new JSONObject();
  JSONObject northeast = new JSONObject();
  JSONObject southwest = new JSONObject();
  northeast.put("lat", latLngBounds.northeast.latitude);
  northeast.put("lng", latLngBounds.northeast.longitude);
  southwest.put("lat", latLngBounds.southwest.latitude);
  southwest.put("lng", latLngBounds.southwest.longitude);
  result.put("northeast", northeast);
  result.put("southwest", southwest);
  
  JSONArray latLngArray = new JSONArray();
  latLngArray.put(northeast);
  latLngArray.put(southwest);
  result.put("latLngArray", latLngArray);
  
  callbackContext.success(result);
}
 
开发者ID:AdrianBZG,项目名称:PhoneChat,代码行数:26,代码来源:PluginMap.java

示例3: getAutocompleteResults

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
public Observable<PlacePrediction> getAutocompleteResults(final GoogleApiClient mGoogleApiClient, final String query, final LatLngBounds bounds) {
    return Observable.create(new Observable.OnSubscribe<PlacePrediction>() {
        @Override
        public void call(Subscriber<? super PlacePrediction> subscriber) {

            PendingResult<AutocompletePredictionBuffer> results =
                    Places.GeoDataApi.getAutocompletePredictions(mGoogleApiClient, query,
                            bounds, null);

            AutocompletePredictionBuffer autocompletePredictions = results
                    .await(60, TimeUnit.SECONDS);

            final Status status = autocompletePredictions.getStatus();
            if (!status.isSuccess()) {
                autocompletePredictions.release();
                subscriber.onError(null);
            } else {
                for (AutocompletePrediction autocompletePrediction : autocompletePredictions) {
                    subscriber.onNext(
                            new PlacePrediction(
                                    autocompletePrediction.getPlaceId(),
                                    autocompletePrediction.getDescription()
                            ));
                }
                autocompletePredictions.release();
                subscriber.onCompleted();
            }
        }
    });
}
 
开发者ID:sathishmscict,项目名称:Pickr,代码行数:31,代码来源:DataManager.java

示例4: onCreate

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_liveshare);
        builder = new LatLngBounds.Builder();
        userdata = FirebaseDatabase.getInstance().getReference().child(Constants.users);

        user = FirebaseAuth.getInstance().getCurrentUser();
        key = (String) getIntent().getExtras().get("uid");
        livedata = FirebaseDatabase.getInstance().getReference(Constants.events).child(key).child(Constants.livepart);
        lat = (Double) getIntent().getExtras().get("lat");
        lon = (Double) getIntent().getExtras().get("lon");
        builder.include(new LatLng(lat,lon));

        SupportMapFragment mapFragment =
                (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
//            Intent  i = new Intent(getApplicationContext(), LocationData.class);
//            startService(i);


    }
 
开发者ID:picopalette,项目名称:event-me,代码行数:23,代码来源:LiveShare.java

示例5: onClusterClick

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
@Override
public boolean onClusterClick(Cluster<CustomMarker> cluster) {
    // Zoom in the cluster. Need to create LatLngBounds and including all the cluster items
    // inside of bounds, then animate to center of the bounds.
    // Create the builder to collect all essential cluster items for the bounds.
    LatLngBounds.Builder builder = LatLngBounds.builder();
    for (CustomMarker item : cluster.getItems()) {
        builder.include(item.getPosition());
    }
    // Get the LatLngBounds
    final LatLngBounds bounds = builder.build();

    // Animate camera to the bounds
    try {
        mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 150));
    } catch (Exception e) {
        e.printStackTrace();
    }

    return true;
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:22,代码来源:CustomRenderer.java

示例6: PlacePinAndPositionCamera

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
public void PlacePinAndPositionCamera(LatLng addressPosition) {

        MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.position(addressPosition);
        mMap.addMarker(markerOptions
                .title("Crisis Location").icon(BitmapDescriptorFactory
                        .defaultMarker(BitmapDescriptorFactory.HUE_RED)));
        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(addressPosition, 12));
        LatLngBounds.Builder builder = new LatLngBounds.Builder();

        builder.include(addressPosition);

        LatLngBounds bounds = builder.build();

        int padding = 150; // offset from edges of the map in pixels
        CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);

        mMap.animateCamera(cu);
    }
 
开发者ID:panzerama,项目名称:Dispatch,代码行数:20,代码来源:MainActivity.java

示例7: onMapReady

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    // Add a marker in Sydney, Australia, and move the camera.
    LatLng stationLocation = new LatLng(mStation.getLatitude(), mStation.getLongitude());
    mMap.addMarker(new MarkerOptions().position(stationLocation).title(mStation.getLocalizedName()));
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(stationLocation, 15));
    mMap.setBuildingsEnabled(true);
    mMap.setTrafficEnabled(false);
    mMap.setMinZoomPreference(10);
    mMap.setMaxZoomPreference(18);
    mMap.setLatLngBoundsForCameraTarget(new LatLngBounds(stationLocation,stationLocation));
    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
        mMap.setMyLocationEnabled(true);
    }
}
 
开发者ID:hyperrail,项目名称:hyperrail-for-android,代码行数:18,代码来源:StationActivity.java

示例8: updateUI

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
private void updateUI() {
    if (mMap == null || mMapImage == null) {
        return;
    }
    Log.d(TAG, "updateUI: ");
    LatLng itemPoint = new LatLng(mMapItem.getLat(), mMapItem.getLon());
    LatLng myPoint = new LatLng(mCurrentLocation.getLatitude(),
            mCurrentLocation.getLongitude());
    BitmapDescriptor itemBitmap = BitmapDescriptorFactory.fromBitmap(mMapImage);
    MarkerOptions itemMarker = new MarkerOptions()
            .position(itemPoint)
            .icon(itemBitmap);
    MarkerOptions myMarker = new MarkerOptions()
            .position(myPoint);
    mMap.clear();
    mMap.addMarker(itemMarker);
    mMap.addMarker(myMarker);
    LatLngBounds bounds = new LatLngBounds.Builder()
            .include(itemPoint)
            .include(myPoint)
            .build();
    int margin = getResources().getDimensionPixelSize(R.dimen.map_inset_margin);
    CameraUpdate update = CameraUpdateFactory.newLatLngBounds(bounds, margin);
    mMap.animateCamera(update);
}
 
开发者ID:ivicel,项目名称:Android-Programming-BigNerd,代码行数:26,代码来源:LocatrFragment.java

示例9: refreshMarkers

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
private void refreshMarkers() {
//        if (allMarkers.size() == allTrips.size()) return;
        LatLngBounds.Builder boundBuilder = new LatLngBounds.Builder();
        allMarkers.clear();
        gMap.clear();
        for (Trip t : allTrips) {
            DateTime begDate = DateTime.parse(t.getStartDate());
            DateTime endDate = DateTime.parse(t.getEndDate());
            LatLng thisLoc = new LatLng(t.getLat(), t.getLng());
            Marker m = gMap.addMarker(
                    new MarkerOptions().position(thisLoc).title(t.getName())
                            .snippet(formatDate(begDate, endDate)));
            m.setTag(t);
            allMarkers.add(m);
            boundBuilder.include(thisLoc);
        }
        if (allMarkers.size() > 0) {
            int screenWidth = getResources().getDisplayMetrics().widthPixels;
            int screenHeight = getResources().getDisplayMetrics().heightPixels;
            LatLngBounds bound = boundBuilder.build();
            CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bound,
                    screenWidth, screenHeight, 56);
            gMap.animateCamera(cameraUpdate);
        }
    }
 
开发者ID:gvsucis,项目名称:mobile-app-dev-book,代码行数:26,代码来源:TripMapFragment.java

示例10: getBoundingBox

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
/**
 * Get the WGS84 bounding box of the current map view screen.
 * The max longitude will be larger than the min resulting in values larger than 180.0.
 *
 * @param map google map
 * @return current bounding box
 */
public static BoundingBox getBoundingBox(GoogleMap map) {

    LatLngBounds visibleBounds = map.getProjection()
            .getVisibleRegion().latLngBounds;
    LatLng southwest = visibleBounds.southwest;
    LatLng northeast = visibleBounds.northeast;

    double minLatitude = southwest.latitude;
    double maxLatitude = northeast.latitude;

    double minLongitude = southwest.longitude;
    double maxLongitude = northeast.longitude;
    if (maxLongitude < minLongitude) {
        maxLongitude += (2 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH);
    }

    BoundingBox boundingBox = new BoundingBox(minLongitude, minLatitude, maxLongitude, maxLatitude);

    return boundingBox;
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:28,代码来源:MapUtils.java

示例11: fitMap

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
public void fitMap(GoogleMap map, List<LatLng> locations, boolean animate, int padding) {
    if (map == null) {
        return;
    }
    LatLngBounds bounds = getLatLngBounds(locations);
    if (bounds == null ) {
        return;
    }
    CameraUpdate cUpdate = null;
    try {
        cUpdate = CameraUpdateFactory.newLatLngBounds(bounds, padding);
        if (animate) {
            map.animateCamera(cUpdate);
        } else {
            map.moveCamera(cUpdate);
        }
    } catch (Exception e) {
        Log.e(TAG, e != null && e.getMessage() != null ? e.getMessage() : "");
    }
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:21,代码来源:MeasurementsGoogleMapHelper.java

示例12: updateMapArea

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
/**
 * Zooms in on map based most recent or previous day's graph.
 *
 * Uses the first day's location as the first point and
 * the last location of graph as the last point for area to zoom
 * in on around the map.
 *
 * Calls drawGraph(graph) to show graph points.
 */
@Override
public void updateMapArea() {
    Graph graph = mapPresenter.getRecentGraph();
    if (googleMap == null){
        Log.d(TAG, "Google map is null");
        return;
    }

    Location first = graph.getLocations().get(0);
    Location last = graph.getLocations().get(graph.getLocations().size() - 1);
    LatLng firstPoint = new LatLng(first.getLatitude(), first.getLongitude());
    LatLng lastPoint = new LatLng(last.getLatitude(), last.getLongitude());


    LatLngBounds bounds = new LatLngBounds.Builder()
            .include(firstPoint)
            .include(lastPoint)
            .build();
    int margin = getResources().getDimensionPixelSize(R.dimen.map_inset);
    CameraUpdate update = CameraUpdateFactory.newLatLngBounds(bounds, margin);
    googleMap.animateCamera(update);
    drawGraph(graph);
}
 
开发者ID:aumarbello,项目名称:WalkGraph,代码行数:33,代码来源:MapFragmentImpl.java

示例13: updateMapPOIs

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
private void updateMapPOIs() {
    googleMap.clear();
    if (hits.isEmpty()) {
        return;
    }
    LatLngBounds.Builder builder = new LatLngBounds.Builder();
    for (final JSONObject hit: hits) {
        final MarkerOptions marker = HitMarker.marker(hit);
        builder.include(marker.getPosition());
        googleMap.addMarker(marker);
    }
    LatLngBounds bounds = builder.build();
    // update the camera
    int padding = 10;
    CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
    googleMap.animateCamera(cu);
}
 
开发者ID:algolia,项目名称:instantsearch-android-examples,代码行数:18,代码来源:MapWidget.java

示例14: addPanPropertiesToMap

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
private void addPanPropertiesToMap() {
	LatLngBounds bounds = null;
	Builder latLngBoundBuilder = new LatLngBounds.Builder();
	if (punchLocationCollection != null && punchLocationCollection.size() > 0) {
		int totalLocations = punchLocationCollection.size();
		for (int currentLocation = 0; currentLocation < totalLocations; currentLocation++) {
			LatLng latLng = new LatLng(Double.parseDouble(punchLocationCollection.get(currentLocation).getLatitude()), Double.parseDouble(punchLocationCollection.get(currentLocation)
					.getLongitude()));
			latLngBoundBuilder = latLngBoundBuilder.include(latLng);
		}
	}

	if (deviceCurrentLocation != null) {
		latLngBoundBuilder.include(new LatLng(deviceCurrentLocation.getLatitude(), deviceCurrentLocation.getLongitude()));
	}

	// Build the map with the bounds that encompass all the
	// specified location as well the current location
	bounds = latLngBoundBuilder.build();

	mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50));
	// Zoom in, animating the camera.
	// mMap.animateCamera(CameraUpdateFactory.zoomTo(50), 2000, null);
}
 
开发者ID:appez,项目名称:appez-android,代码行数:25,代码来源:SmartMapHandlerActivity.java

示例15: showAvailableRestaurants

import com.google.android.gms.maps.model.LatLngBounds; //导入依赖的package包/类
@Override
public void showAvailableRestaurants(List<Restaurant> items) {
    LatLngBounds.Builder builder = new LatLngBounds.Builder();
    for (Restaurant restaurant : items) {
        Marker marker = this.googleMap.addMarker(
                new MarkerOptions()
                        .position(new LatLng(restaurant.latitude, restaurant.longitude))
                        .title(restaurant.name)
                        .icon(BitmapDescriptorFactory.fromResource(R.drawable.mikuy_marker))
                        .snippet(restaurant.category));
        marker.setTag(restaurant);
        builder.include(marker.getPosition());
    }
    LatLngBounds bounds = builder.build();
    CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 100);
    this.googleMap.moveCamera(cu);
}
 
开发者ID:Danihelsan,项目名称:MikuyConcept,代码行数:18,代码来源:ExploreFragment.java


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