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


Java CameraUpdateFactory.newLatLngBounds方法代码示例

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


在下文中一共展示了CameraUpdateFactory.newLatLngBounds方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PlacePinAndPositionCamera

import com.google.android.gms.maps.CameraUpdateFactory; //导入方法依赖的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

示例2: updateUI

import com.google.android.gms.maps.CameraUpdateFactory; //导入方法依赖的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

示例3: refreshMarkers

import com.google.android.gms.maps.CameraUpdateFactory; //导入方法依赖的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

示例4: fitMap

import com.google.android.gms.maps.CameraUpdateFactory; //导入方法依赖的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

示例5: updateMapArea

import com.google.android.gms.maps.CameraUpdateFactory; //导入方法依赖的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

示例6: onMapReady

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

    //crt list
    crt[0] = new crtLocation(36.796043,10.176679 ,"Rue de Angleterre, Tunis");
    crt[1] = new crtLocation(36.811240,10.168087 ,"DNSP, Rue du Fort, Tunis");
    crt[2] = new crtLocation(36.768390,10.231351 ,"Centre National de Formation des volontaires");
    crt[3] = new crtLocation(36.765738,10.249805 ,"Comité Local megrine");
    crt[4] = new crtLocation(36.857147,10.188060 ,"Croissant Rouge Tunisien");
    crt[5] = new crtLocation(35.857905,10.598179 ,"comité local Hammam Sousse");
    crt[6] = new crtLocation(34.731843,10.759640,"Rue El Arbi Zarrouk, Sfax");
    crt[7] = new crtLocation(33.504106,11.088150 ,"Mouensa, Zarzis ");
    crt[8] = new crtLocation(36.441899,10.729911 ," Comité Regional De Nabeul");
    crt[9] = new crtLocation( 35.829321,10.638072 ,"Comité Local de Sousse");
    crt[10] = new crtLocation(33.137021,11.220034 ,"Comité Local Benguerdane");
    LatLngBounds.Builder builder = new LatLngBounds.Builder();
    for (int i = 0;i<11;i++) {
         marker = map.addMarker(new MarkerOptions()
                .position(new LatLng(crt[i].getX(), crt[i].getY()))
                .title("Croissant Rouge Tunisien")
                .snippet(crt[i].getAdresse()));
        builder.include(marker.getPosition());
    }

    


    LatLngBounds bounds = builder.build();
    int padding = 0; // offset from edges of the map in pixels
    CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
    googleMap.animateCamera(cu);
}
 
开发者ID:RRDL,项目名称:CRT,代码行数:34,代码来源:Notification.java

示例7: updateUI

import com.google.android.gms.maps.CameraUpdateFactory; //导入方法依赖的package包/类
private void updateUI() {
    if (mMap == null || mMapImage == null) {
        return;
    }

    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:rsippl,项目名称:AndroidProgramming3e,代码行数:29,代码来源:LocatrFragment.java

示例8: recapDisplayTrack

import com.google.android.gms.maps.CameraUpdateFactory; //导入方法依赖的package包/类
/**
 * Display the given Track on the given GoogleMap. The argument color indicates the desired color for
 * the Track to be shown. Also takes care to center the camera on the displayed Track. Used for recaps
 *
 * @param track  Track to be shown
 * @param googleMap map where the Track must be shown
 * @param color color for the Track to be shown
 */
public static void recapDisplayTrack(Track track, GoogleMap googleMap, int color) {
    if(track == null || googleMap == null) {
        throw new IllegalArgumentException();
    }

    if (track.getTotalCheckPoints() != 0) {
        // Build polyline and latitude, longitude bounds
        PolylineOptions polylineOptions = new PolylineOptions();
        List<CheckPoint> trackPoints = track.getCheckpoints();
        LatLngBounds.Builder builder = new LatLngBounds.Builder();

        for (CheckPoint checkPoint : trackPoints) {
            LatLng latLng = new LatLng(checkPoint.getLatitude(), checkPoint.getLongitude());
            polylineOptions.add(latLng);
            builder.include(latLng);
        }

        googleMap.addPolyline(polylineOptions.color(color));

        // Center camera on past run
        LatLngBounds bounds = builder.build();
        int padding = 40;
        CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, padding);
        googleMap.animateCamera(cameraUpdate);
    }
}
 
开发者ID:IrrilevantHappyLlamas,项目名称:Runnest,代码行数:35,代码来源:UtilsUI.java

示例9: showBothMarkersAndGetDirections

import com.google.android.gms.maps.CameraUpdateFactory; //导入方法依赖的package包/类
private void showBothMarkersAndGetDirections() {
    if (mOriginMapMarker != null && mDestinationMarker != null) {
        int width = getResources().getDisplayMetrics().widthPixels;
        int padding = (int) (width * 0.10); //
        CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(getLatLngBoundsForMarkers(), padding);
        mMap.moveCamera(cu);
        mMap.animateCamera(cu);

        sendRequest(mOriginMapMarker.getPosition(), mDestinationMarker.getPosition());

    } else {

    }
}
 
开发者ID:aliumujib,项目名称:Nibo,代码行数:15,代码来源:NiboOriginDestinationPickerFragment.java

示例10: updateMapView

import com.google.android.gms.maps.CameraUpdateFactory; //导入方法依赖的package包/类
private void updateMapView() {
    if (mMap == null || !isMapLoaded) {
        return;
    }

    if (currentLocationMarker == null && expectedPlace == null) {
        return;
    }

    LatLngBounds.Builder builder = new LatLngBounds.Builder();

    if (currentLocationMarker != null) {
        LatLng current = currentLocationMarker.getPosition();
        builder.include(current);
    }

    if (expectedPlace != null && expectedPlace.getLocation() != null &&
            expectedPlace.getLocation().getLatLng() != null) {
        LatLng destination = expectedPlace.getLocation().getLatLng();
        builder.include(destination);
    }

    LatLngBounds bounds = builder.build();

    try {
        CameraUpdate cameraUpdate;
        if (expectedPlace != null && currentLocationMarker != null) {
            int width = getResources().getDisplayMetrics().widthPixels;
            int height = getResources().getDisplayMetrics().heightPixels;
            int padding = (int) (width * 0.12);
            cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, width, height, padding);
        } else {
            LatLng latLng = currentLocationMarker != null ?
                    currentLocationMarker.getPosition() : expectedPlace.getLocation().getLatLng();
            cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, zoomLevel);
        }

        mMap.animateCamera(cameraUpdate, 1000, null);

    } catch (Exception e) {
        e.printStackTrace();
        Crashlytics.logException(e);
    }
}
 
开发者ID:hypertrack,项目名称:hypertrack-live-android,代码行数:45,代码来源:Home.java

示例11: update

import com.google.android.gms.maps.CameraUpdateFactory; //导入方法依赖的package包/类
/**
 * Update everything after a filter has changed or new data is made available.
 * Here we position the markers on the map and set the bounding viewbox/zoomlevel
 */
@Override
public void update(final Observable observable, final Object o) {
    updateListView();

    if(map == null) {
        final Handler delayHandler = new Handler();
        delayHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                update(observable, o);
            }
        }, 100);
        return;
    }

    map.clear();
    LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
    int n = 0;

    for(int i = 0; i < habitEvents.size(); ++i) {
        HabitEvent event = habitEvents.get(i);
        double lat = event.getLatitude();
        double lng = event.getLongitude();
        if(lat == 0 || lng == 0) continue;
        n++;

        LatLng pos = new LatLng(lat, lng);
        Marker marker = map.addMarker(new MarkerOptions()
            .position(pos)
            .title("Location")
            .snippet(""+i));
        boundsBuilder.include(marker.getPosition());
    }
    
    if(n > 0) {
        LatLngBounds bounds = boundsBuilder.build();
        int width = getResources().getDisplayMetrics().widthPixels;
        int height = getResources().getDisplayMetrics().heightPixels;
        int padding = (int) (width * 0.10); // offset from edges of the map 10% of screen

        CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, width, height, padding);
        map.moveCamera(cu);
    }
}
 
开发者ID:CMPUT301F17T13,项目名称:cat-is-a-dog,代码行数:49,代码来源:HabitHistoryActivity.java


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