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


Java CameraUpdate类代码示例

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


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

示例1: showPointerOnMap

import com.google.android.gms.maps.CameraUpdate; //导入依赖的package包/类
private void showPointerOnMap(final double latitude, final double longitude) {
    mvRestaurantLocation.getMapAsync(new OnMapReadyCallback() {
        @Override
        public void onMapReady(GoogleMap googleMap) {
            LatLng latLng = new LatLng(latitude, longitude);
            googleMap.addMarker(new MarkerOptions()
                    .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_flag))
                    .anchor(0.0f, 1.0f)
                    .position(latLng));
            googleMap.getUiSettings().setMyLocationButtonEnabled(false);
            googleMap.getUiSettings().setZoomControlsEnabled(true);

            // Updates the location and zoom of the MapView
            CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 15);
            googleMap.moveCamera(cameraUpdate);
        }
    });
}
 
开发者ID:pranayairan,项目名称:YelpQL,代码行数:19,代码来源:BusinessDetailsActivity.java

示例2: updateCamera

import com.google.android.gms.maps.CameraUpdate; //导入依赖的package包/类
/**
 * Updates camera
 * @param shouldAnimate flag indicating if the camera should be animated or moved immediately
 * @param zoom zoom level
 */
private void updateCamera(boolean shouldAnimate, float zoom){

    if(MapLayout.location ==null)
        return;

    CameraPosition.Builder cameraPositionBuilder = new CameraPosition.Builder().target(MapLayout.location);

    cameraPositionBuilder.zoom(zoom);

    CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPositionBuilder.build());

    if(shouldAnimate)
        mGoogleMap.animateCamera(cameraUpdate);
    else
        mGoogleMap.moveCamera(cameraUpdate);
}
 
开发者ID:Ubudu,项目名称:GoogleMapsLayout-Android,代码行数:22,代码来源:MapLayout.java

示例3: PlacePinAndPositionCamera

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

示例4: showColegiElectoralData

import com.google.android.gms.maps.CameraUpdate; //导入依赖的package包/类
public void showColegiElectoralData(final ColegiElectoral colegiElectoral) {
    LatLng latLng = new LatLng(colegiElectoral.getLat(), colegiElectoral.getLon());
    CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 16);
    mGoogleMap.animateCamera(cameraUpdate);

    txtNomLocal.setText(colegiElectoral.getLocal());
    txtAdresa.setText(colegiElectoral.getAdresa());
    txtLocalitat.setText(colegiElectoral.getMunicipi());
    txtDistricte.setText(colegiElectoral.getDistricte() != null ? StringsManager.getString("data_districte", colegiElectoral.getDistricte()) : "");
    txtSeccio.setText(colegiElectoral.getSeccio() != null ? StringsManager.getString("data_seccio", colegiElectoral.getSeccio()) : "");
    txtMesa.setText(colegiElectoral.getMesa() != null ? StringsManager.getString("data_mesa", colegiElectoral.getMesa()) : "");

    icnCalendari.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            addEventToCalendar(colegiElectoral);
        }
    });

    bsb.setState(BottomSheetBehavior.STATE_EXPANDED);
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:22,代码来源:VoteFragment.java

示例5: gotoLocation

import com.google.android.gms.maps.CameraUpdate; //导入依赖的package包/类
/**
 * For actually moving the map to the desired location.
 * @param fctx
 * @param loc
 */
public static void gotoLocation(Activity fctx, Location loc) {
    Location locc = loc;
    sloc = loc;
    if(loc == null){
        locc = getCurrentLocation(fctx);
    }
    if(code == AddHabitEventActivity.EVENT_PERMISSION_CHECK){
    }

    float zoom = 15.0f;
    if(locc == null){
        DummyMainActivity.toastMe("Could not get location", fctx);
    }else{
        double[] d = {locc.getLatitude(), locc.getLongitude()};
        AddHabitEventActivity.setLocation(d);

        LatLng ll = new LatLng(locc.getLatitude(), locc.getLongitude());
        CameraUpdate update = CameraUpdateFactory.newLatLngZoom(ll, zoom);
        gmap.moveCamera(update);
    }
}
 
开发者ID:CMPUT301F17T17,项目名称:Habitizer,代码行数:27,代码来源:MapController.java

示例6: updateUI

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

示例7: refreshMarkers

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

示例8: fitMap

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

示例9: updateMapArea

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

示例10: updateMapPOIs

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

示例11: onMapReady

import com.google.android.gms.maps.CameraUpdate; //导入依赖的package包/类
/**
 * Manipulates the map once available.
 * This callback is triggered when the map is ready to be used.
 * This is where we can add markers or lines, add listeners or move the camera. In this case,
 * we just add a marker near Sydney, Australia.
 * If Google Play services is not installed on the device, the user will be prompted to install
 * it inside the SupportMapFragment. This method will only be triggered once the user has
 * installed Google Play services and returned to the app.
 */
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    mMap.setBuildingsEnabled(true);
    mMap.setIndoorEnabled(true);
    if (MiscHelper.isPermitted(this, Manifest.permission.ACCESS_FINE_LOCATION) &&
        MiscHelper.isPermitted(this, Manifest.permission.ACCESS_COARSE_LOCATION)) {
        mMap.setMyLocationEnabled(true); // Ignore this
        Location location = getCurrentLocation();
        if(location != null) {
            CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 20);
            mMap.moveCamera(cameraUpdate);
            onLocationChanged(location);
        }
    } else{
        ActivityCompat.requestPermissions(
                this,
                new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION},
                CODE_GET_GPS_PERMISSION
        );
    }
}
 
开发者ID:PatrickShaw,项目名称:SpotlessGHack-Intellibins-Android,代码行数:32,代码来源:MapsActivity.java

示例12: showAvailableRestaurants

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

示例13: myAnimateCamera

import com.google.android.gms.maps.CameraUpdate; //导入依赖的package包/类
/**
 * Move the camera of the map
 * @param cameraUpdate
 * @param durationMS
 * @param callbackContext
 */
private void myAnimateCamera(final CameraUpdate cameraUpdate, final int durationMS, final CallbackContext callbackContext) {
  GoogleMap.CancelableCallback callback = new GoogleMap.CancelableCallback() {
    @Override
    public void onFinish() {
      callbackContext.success(ANIMATE_CAMERA_DONE);
    }

    @Override
    public void onCancel() {
      callbackContext.success(ANIMATE_CAMERA_CANCELED);
    }
  };

  if (durationMS > 0) {
    map.animateCamera(cameraUpdate, durationMS, callback);
  } else {
    map.animateCamera(cameraUpdate, callback);
  }
}
 
开发者ID:AdrianBZG,项目名称:PhoneChat,代码行数:26,代码来源:PluginMap.java

示例14: loadMapPins

import com.google.android.gms.maps.CameraUpdate; //导入依赖的package包/类
private void loadMapPins(List<Unit> units) {
    mMap.clear();
    LatLngBounds.Builder builder = new LatLngBounds.Builder();
    for (Unit u : units) {
        mMap.addMarker(new MarkerOptions()
                .title(u.getNome())
                .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_action_pin))
                .snippet(u.buildSnippet())
                .position(new LatLng(u.getGeo().getLatitude(), u.getGeo().getLongitude())));
        builder.include(new LatLng(u.getGeo().getLatitude(), u.getGeo().getLongitude()));
    }

    LatLngBounds bounds = builder.build();
    int padding = (int) (16 * getResources().getDisplayMetrics().density);
    CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, padding);
    mMap.animateCamera(cu);
}
 
开发者ID:gkaffka,项目名称:simple-map-android,代码行数:18,代码来源:ActivityMap.java

示例15: moveToSingle

import com.google.android.gms.maps.CameraUpdate; //导入依赖的package包/类
private void moveToSingle(Adapter adapter, int index, boolean animate) {
    CameraPosition cp = adapter.getCameraPosition(index);
    CameraUpdate cu;
    if (cp != null && cp.target != null
            && cp.target.latitude != 0.0
            && cp.target.longitude != 0.0) {
        cu = CameraUpdateFactory.newCameraPosition(cp);
        if (hidden) showMarkers();
        if (markers.get(index) != null) markers.get(index).showInfoWindow();
    }
    else {
        cu = defaultPosition;
        hideInfoWindowSingle();
    }
    if (animate) map.animateCamera(cu);
    else map.moveCamera(cu);
}
 
开发者ID:nitrico,项目名称:MapViewPager,代码行数:18,代码来源:MapViewPager.java


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