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


Java GoogleMap.moveCamera方法代码示例

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


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

示例1: enableSubMap

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
public void enableSubMap(GoogleMap subMap) {
    mMaps.add(MAP_CODE_SUB, subMap);
    mMapTiles.add(MAP_CODE_SUB, null);

    subMap.setMapType(MAP_TYPE_HYBRID);
    subMap.moveCamera(CameraUpdateFactory.newCameraPosition(mMaps.get(MAP_CODE_MAIN).getCameraPosition()));
    onCameraMove();

    // 在Activity和Map物件註冊ClusterManager
    mClusterManagers.add(MAP_CODE_SUB, new ClusterManager<CustomMarker>(mContext, subMap));
    // The Rule about Cluster Managing
    mClusterManagers.get(MAP_CODE_SUB).setRenderer(
            new CustomRenderer(mContext, subMap, mClusterManagers.get(MAP_CODE_SUB)));
    mClusterManagers.get(MAP_CODE_SUB).setOnClusterClickListener(
            (CustomRenderer) mClusterManagers.get(MAP_CODE_SUB).getRenderer());
    // Click on marker to open infoWindow
    subMap.setOnMarkerClickListener(mClusterManagers.get(MAP_CODE_SUB));
    // Click on Cluster to zoom to Markers
    subMap.setOnCameraIdleListener(this);

    // Test for new info window
    subMap.setInfoWindowAdapter(new CustomAdapter(mContext));
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:24,代码来源:MapsManager.java

示例2: onMapReady

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
/**
 * Manipulates the map once available.
 * This callback is triggered when the map is ready to be used.
 */
@Override
public void onMapReady(GoogleMap map) {
    mMap = map;
    mMapsManager = new MapsManager(this, map);
    mGpxManager = new GpxManager(this);

    // Check whether this app could get location
    if (checkLocationPermission())
        map.setMyLocationEnabled(true);
    else
        askPermission();

    // Set the boundaries of Taiwan
    MapUtils.setTaiwanBoundaries(map);

    // 設定相機位置
    if (lastCameraPosition == null)
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(TAIWAN_CENTER, STARTING_ZOOM));
    else
        map.moveCamera(CameraUpdateFactory.newCameraPosition(lastCameraPosition));
    mMapsManager.onCameraMove();

    // 開啟上次的GPX檔案
    if (!mGpxFileList.isEmpty()) {
        for (String filePath : mGpxFileList) {
            File file = new File(filePath);
            mGpxManager.addGpxFile(file, mMapsManager);
        }
        mGpxManager.refreshDialog();
    }

    // TODO blue dot beam to indicate user direction
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:38,代码来源:MapsActivity.java

示例3: autoZoom

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
private void autoZoom() {
    GoogleMap gm = getMap();
    if (gm == null)
        return;

    if (m_llb == null) {
        Location l = MFBLocation.LastSeenLoc();
        if (l != null)
            gm.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(l.getLatitude(), l.getLongitude()), ZOOM_LEVEL_AREA));
    } else {
        double height = Math.abs(m_llb.northeast.latitude - m_llb.southwest.latitude);
        double width = Math.abs(m_llb.northeast.longitude - m_llb.southwest.longitude);

        gm.moveCamera(CameraUpdateFactory.newLatLngBounds(m_llb, 20));
        if (height < 0.001 || width < 0.001)
            gm.moveCamera(CameraUpdateFactory.zoomTo((m_rgapRoute != null && m_rgapRoute.length == 1) ? ZOOM_LEVEL_AIRPORT : ZOOM_LEVEL_AREA));
    }
}
 
开发者ID:ericberman,项目名称:MyFlightbookAndroid,代码行数:19,代码来源:ActFlightMap.java

示例4: onMapReady

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
/**
 * Run this code when the map has been loaded and is ready
 * @param googleMap the map
 */
@Override
public void onMapReady(GoogleMap googleMap) {
    map = googleMap;
    googleMap.setLatLngBoundsForCameraTarget(null);
    googleMap.setMinZoomPreference(6.0f);
    // Add a marker in Sydney, Australia,
    // and move the map's camera to the same location.

    if(location != null) {
        LatLng loc = new LatLng(location.getLatitude(), location.getLongitude());
        map.addMarker(new MarkerOptions().position(loc)
                .title("Location"));
        map.moveCamera(CameraUpdateFactory.newLatLng(loc));
    } else {
        LatLng sydney = new LatLng(-33.852, 151.211);
        googleMap.addMarker(new MarkerOptions().position(sydney)
                .title("Location"));
        googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
    }
}
 
开发者ID:CMPUT301F17T13,项目名称:cat-is-a-dog,代码行数:25,代码来源:AddHabitEventActivity.java

示例5: initMap

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
protected void initMap(GoogleMap map) {
    goToLocation = true;
    firstLocationRefresh = true;
    if (map != null) {
        MapsInitializer.initialize(getActivity());
        RAApplication.getInstance().getGpsDetector().setGpsMapListener(new GPSDetector.GpsMapListener() {
            @Override
            public void onGpsMapListener(final Location location) {
                ActivityUtil.runOnMainThread(new Runnable() {
                    @Override
                    public void run() {
                        if (refreshMyLocation) {
                            setCurrentLocation(location);
                        }
                    }
                });
            }
        });
        clearMap();
        LatLng loc = new LatLng(Constants.LATITUDE_BELARUS, Constants.LONGITUDE_BELARUS);
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(loc, Constants.DEFAULT_CAMERA_ZOOM));
        refreshMyLocation(loc);
        initMapData();
    }
}
 
开发者ID:WorldBank-Transport,项目名称:RoadLab-Pro,代码行数:26,代码来源:BaseStartMeasurementMapFragment.java

示例6: fitMap

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

示例7: onMapReady

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
/**
 * Add map markers for all events that have valid locations
 */
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    LatLngBounds.Builder builder = new LatLngBounds.Builder();

    // whether there is atleast one event with a location to be displayed on the map or not
    boolean atleastOneEvent = false;

    for (CompletedEventDisplay event : events){
        Location location = event.getLocation();
        if (location != null){
            LatLng coordinates = new LatLng(location.getLatitude(), location.getLongitude());
            builder.include(coordinates);
            atleastOneEvent = true;
            mMap.addMarker(new MarkerOptions().position(coordinates).title(event.getDescriptionWithLocation(this)));
        }
    }

    /**
     * This, along with the LatLngBounds.Builder part of this method is based off of andr's answer:
     * https://stackoverflow.com/a/14828739
     *
     * The width, height, padding aspects of newLatLngBounds() is from:
     * https://github.com/OneBusAway/onebusaway-android/issues/581
     */
    if (atleastOneEvent) {
        mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), getResources().getDisplayMetrics().widthPixels,
                getResources().getDisplayMetrics().heightPixels, (int) Math.ceil(0.12 * getResources().getDisplayMetrics().widthPixels)));
    } else {
        // move the map to the device's current location
        Location deviceLoc = LocationUtilities.getLocation(this);
        if (deviceLoc != null)
            googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(deviceLoc.getLatitude(), deviceLoc.getLongitude()), 30));
    }
}
 
开发者ID:CMPUT301F17T15,项目名称:CIA,代码行数:39,代码来源:ViewEventsMapActivity.java

示例8: boundMap

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
private static void boundMap(final boolean isListView, final LatLngBounds.Builder builder, final GoogleMap googleMap) {
    LatLngBounds bounds = builder.build();
    googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 50));
    float zoom = googleMap.getCameraPosition().zoom;
    if (isListView)
        googleMap.moveCamera(CameraUpdateFactory.zoomTo(zoom - 1f));
}
 
开发者ID:bkhezry,项目名称:ExtraMapUtils,代码行数:8,代码来源:MapUtils.java

示例9: moveCameraToKml

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
public static void moveCameraToKml(KmlLayer kmlLayer, GoogleMap googleMap) {
    //TODO fixed error with some kml file https://developers.google.com/maps/documentation/android-api/utility/kml
    //Only use in this kml file correctly.
    LatLngBounds.Builder builder = new LatLngBounds.Builder();
    KmlContainer container = kmlLayer.getContainers().iterator().next();
    container = container.getContainers().iterator().next();
    KmlPlacemark placemark = container.getPlacemarks().iterator().next();

    KmlPolygon polygon = (KmlPolygon) placemark.getGeometry();
    for (LatLng latLng : polygon.getOuterBoundaryCoordinates()) {
        builder.include(latLng);
    }

    googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 50));
}
 
开发者ID:bkhezry,项目名称:ExtraMapUtils,代码行数:16,代码来源:MapUtils.java

示例10: onMapReady

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
    float zoomLevel = (float) 16.0;
    LatLng coordenadas = new LatLng(evento.getLatitud(), evento.getLongitud());
    googleMap.addMarker(new MarkerOptions().position(coordenadas).title(evento.getTitulo()));
    googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(coordenadas, zoomLevel));
}
 
开发者ID:ur13l,项目名称:Guanajoven,代码行数:8,代码来源:DetalleEventoFragment.java

示例11: onMapReady

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
    float zoomLevel = (float) 16.0;
    LatLng coordenadas = new LatLng(region.getLatitud(), region.getLongitud());
    googleMap.addMarker(new MarkerOptions().position(coordenadas).title(region.getNombre()));
    googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(coordenadas, zoomLevel));
}
 
开发者ID:ur13l,项目名称:Guanajoven,代码行数:8,代码来源:DetalleRegionFragment.java

示例12: onMapReady

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


        for(int i=0;i<PicList.size();i++)
        {
            LatLng place = new LatLng(Double.valueOf(PicList.get(i).get_latitude()),Double.valueOf(PicList.get(i).get_longitude()));

            //make small size icon
            Bitmap smallMarker = Bitmap.createScaledBitmap(imgeHelper.getBitmapFromByteArray(PicList.get(i).get_thumbnail()), 70, 70, false);
            googleMap.addMarker(new MarkerOptions().position(place)
                    .title(PicList.get(i).get_city())).setIcon(BitmapDescriptorFactory.fromBitmap(smallMarker));

            googleMap.moveCamera(CameraUpdateFactory.newLatLng(place));

            // Set a listener for marker click.
            googleMap.setOnMarkerClickListener(this);
            //this listener is listening the events that you click on the title of the map marker
            googleMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
                @Override
                public void onInfoWindowClick(Marker marker) {

                    DBHelper dbHelper = new DBHelper(getContext(), "Picture.db", null, 1);
                    picCities = dbHelper.selectPicFromCity(marker.getTitle());


                    //send data to citygallery activity
                    Intent intent = new Intent(getContext(), CItyGalleryActivity.class);
                    intent.putExtra("cityChoise",picCities.get(0).get_city().toString());
                    startActivity(intent);

                    dbHelper.close();

                }
            });
        }


    }
 
开发者ID:peterdestasio,项目名称:Geoclick,代码行数:39,代码来源:MapViewFragment.java

示例13: setUpMap

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
public void setUpMap(GoogleMap googleMap) {

		LatLng pinPosition = new LatLng(rack.getLatitude(), rack.getLongitude());
		googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(pinPosition, 18));
		googleMap.addMarker(new MarkerOptions()
				.position(pinPosition)
				.icon(AssetHelper.getCustomPin(rack.getAverageRating(), false)));
	}
 
开发者ID:EduardoVernier,项目名称:bikedeboa-android,代码行数:9,代码来源:DetailViewModel.java

示例14: onMapReady

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
    SummaryActivity.this.googleMap = googleMap;
    googleMap.setTrafficEnabled(false);
    googleMap.setBuildingsEnabled(false);
    googleMap.setOnMyLocationButtonClickListener(this);

    UiSettings mapUi = googleMap.getUiSettings();
    mapUi.setMapToolbarEnabled(false);
    mapUi.setAllGesturesEnabled(true);
    mapUi.setTiltGesturesEnabled(false);
    mapUi.setMyLocationButtonEnabled(true);

    for (MarkerOptions markerOptions : pendingMarkersList)
        addMarker(markerOptions);
    pendingMarkersList.clear();

    followUser = true;
    if (ActivityCompat.checkSelfPermission(SummaryActivity.this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)
        googleMap.setMyLocationEnabled(true);

    Location location = LocationService.getBestLastKnownLocation(SummaryActivity.this);
    if (location != null) {
        LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
        googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
        googleMap.moveCamera(CameraUpdateFactory.zoomTo(18));
    }
}
 
开发者ID:gvinciguerra,项目名称:custode,代码行数:29,代码来源:SummaryActivity.java

示例15: onMapReady

import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
    // Add a marker in Sydney, Australia,
    // and move the map's camera to the same location.
    LatLng sydney = new LatLng(-33.852, 151.211);
    MarkerOptions marker = new MarkerOptions().position(sydney)
            .title("Marker in Sydney");
    googleMap.addMarker(marker);
    googleMap.setOnInfoWindowClickListener(this);
    googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
 
开发者ID:parthdave93,项目名称:AndroidTestingTutorial,代码行数:12,代码来源:MapActivity.java


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