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


Java CameraUpdateFactory类代码示例

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


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

示例1: onMapReady

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

    // Add a marker in Sydney and move the camera
    Intent tmp = getIntent();
    double lat = tmp.getDoubleExtra("lat", 0.0);
    double lon = tmp.getDoubleExtra("lon", 0.0);
    LatLng phoneLocation = new LatLng(lat, lon);
    mMap.addMarker(new MarkerOptions().position(phoneLocation).title("Here i am..."));
    //mMap.animateCamera( CameraUpdateFactory.zoomTo( 17.0f ) );
    //mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(phoneLocation,17));
    //mMap.moveCamera(CameraUpdateFactory.newLatLng(phoneLocation));


    CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(phoneLocation)     // Sets the center of the map to location user
            .zoom(16)                   // Sets the zoom
            .build();                   // Creates a CameraPosition from the builder
    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

}
 
开发者ID:sommukhopadhyay,项目名称:nirbhaya,代码行数:32,代码来源:NirbhayaMapsActivity.java

示例2: zoomToPolyline

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

示例3: onMapReady

import com.google.android.gms.maps.CameraUpdateFactory; //导入依赖的package包/类
@Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;
//        mMap.setOnMapClickListener(this);
        Bundle bundle = getIntent().getExtras();

        double r_long=bundle.getDouble("lattitude");
        double r_lat=bundle.getDouble("longitude");
        // Add a marker in Sydney and move the camera
        LatLng mark = new LatLng(r_lat, r_long);
        CircleOptions circleoptions=new CircleOptions().strokeWidth(2).strokeColor(Color.BLUE).fillColor(Color.parseColor("#500084d3"));
        mMap.addMarker(new MarkerOptions().position(mark).title(getAddress(mark)));
        mMap.moveCamera(CameraUpdateFactory.newLatLng(mark));
        Circle circle=mMap.addCircle(circleoptions.center(mark).radius(5000.0));
        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(circleoptions.getCenter(),getZoomLevel(circle)));
    }
 
开发者ID:jamesgeorge007,项目名称:TrackIn-Android-Application,代码行数:17,代码来源:cordmap.java

示例4: onConnected

import com.google.android.gms.maps.CameraUpdateFactory; //导入依赖的package包/类
@Override
public void onConnected(@Nullable Bundle bundle) {
    //Compruebo los permisos de la localización
    //si no los tengo me salgo del método
    if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED &&
            ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
        //Pongo mi localización en el mapa
        mMap.setMyLocationEnabled(true);
    }else
        ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);

    //Obtengo la última localización conocida
    mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
            mGoogleApiClient);
    if (mLastLocation != null) {
        miPosicion = new LatLng(mLastLocation.getLatitude(),mLastLocation.getLongitude());
        if(mMap!=null)
            mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(miPosicion,12));
    }
}
 
开发者ID:nen155,项目名称:TFG-SmartU-La-red-social,代码行数:21,代码来源:FragmentMapa.java

示例5: addGeoJsonLayerToMap

import com.google.android.gms.maps.CameraUpdateFactory; //导入依赖的package包/类
private static void addGeoJsonLayerToMap(final GeoJsonLayer layer, final GoogleMap googleMap, final Context context, final onGeoJsonEventListener eventListener) {
    Handler mainHandler = new Handler(context.getMainLooper());
    mainHandler.post(new Runnable() {
        @Override
        public void run() {
            layer.addLayerToMap();
            googleMap.moveCamera(CameraUpdateFactory.newLatLngBounds(layer.getBoundingBox(), 50));
            layer.setOnFeatureClickListener(new GeoJsonLayer.GeoJsonOnFeatureClickListener() {
                @Override
                public void onFeatureClick(Feature feature) {
                    if (eventListener != null)
                        eventListener.onFeatureClick(feature);
                }

            });
        }
    });


}
 
开发者ID:bkhezry,项目名称:ExtraMapUtils,代码行数:21,代码来源:MapUtils.java

示例6: onMapReady

import com.google.android.gms.maps.CameraUpdateFactory; //导入依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    // Add a marker in Sydney and move the camera
    LatLng sydney = new LatLng(27.746974, 85.301582);
    mMap.addMarker(new MarkerOptions().position(sydney).title("Kathmandu, Nepal"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
    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) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }
    mMap.setMyLocationEnabled(true);
}
 
开发者ID:JayWilliamsJr,项目名称:Find-It-Location-Finder,代码行数:20,代码来源:MapsActivity.java

示例7: updateTrackPts

import com.google.android.gms.maps.CameraUpdateFactory; //导入依赖的package包/类
private void updateTrackPts(boolean updateAllPts) {
    if (updateAllPts) {
        // 將所有航跡點加入地圖
        for (Location location : mMyTrkpts) {
            mMap.addMarker(TRKPTS_STYLE.position(MapUtils.loc2LatLng(location)));
        }
    } else {
        // 將最新航跡點加入地圖
        mMap.addMarker(TRKPTS_STYLE.position(MapUtils.loc2LatLng(mCurrentLocation)));
    }

    // 將航跡的Polyline更新
    if (!mMyTrkpts.isEmpty())
        mMyTrackOnMap.setPoints(MapUtils.locs2LatLngs(mMyTrkpts));

    // 將攝影機對準最初的航跡點
    if (mMyTrkpts.size() == 1) {
        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
                MapUtils.loc2LatLng(mMyTrkpts.get(0)), 15));
    }
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:22,代码来源:MapsActivity.java

示例8: 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

示例9: moveMapCamera

import com.google.android.gms.maps.CameraUpdateFactory; //导入依赖的package包/类
@Override
public void moveMapCamera(final LatLng latLng) {
    if (latLng.latitude == 0 && latLng.longitude == 0)
        return;
    final CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(latLng)
            .zoom(12f)
            .build();
    googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition),
            new GoogleMap.CancelableCallback() {
                @Override
                public void onFinish() {
                    googleMap.clear();
                    latitude = latLng.latitude;
                    longitude = latLng.longitude;
                    googleMap.addMarker(new MarkerOptions().position(latLng));
                }

                @Override
                public void onCancel() {
                    // ignored
                }
            });
}
 
开发者ID:GrenderG,项目名称:Protestr,代码行数:25,代码来源:CreateEventActivity.java

示例10: onMapReady

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

    if (latitude > 0 && longitude > 0) {

        map = googleMap;
        LatLng area = new LatLng(latitude, longitude);

        map.addMarker(new MarkerOptions().position(area)
                .title("Araç Konumu"));
        map.setMaxZoomPreference(15f);
        map.moveCamera(CameraUpdateFactory.newLatLng(area));
        map.moveCamera(CameraUpdateFactory.zoomBy(1));
    }

}
 
开发者ID:freeloki,项目名称:FordOpenXCHackathon,代码行数:20,代码来源:MainActivity.java

示例11: onSearch

import com.google.android.gms.maps.CameraUpdateFactory; //导入依赖的package包/类
public void onSearch(View view) {
    EditText location_tf = (EditText) findViewById(R.id.TFaddress);
    String location = location_tf.getText().toString();
    List <android.location.Address> addressList = null;
    if (location != null || !location.equals(' ')) {
        Geocoder geocoder = new Geocoder(this);
        try {
            addressList = geocoder.getFromLocationName(location, 1);
        } catch (IOException e) {
            e.printStackTrace();
        }

        android.location.Address address = addressList.get(0);
        LatLng latlng = new LatLng(address.getLatitude() , address.getLongitude());
        mMap.addMarker(new MarkerOptions().position(latlng).title("Marker"));
        mMap.animateCamera(CameraUpdateFactory.newLatLng(latlng));
    }
}
 
开发者ID:GitWebX,项目名称:hubISM,代码行数:19,代码来源:Campus_Map.java

示例12: autoZoom

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

示例13: onGoToVrController

import com.google.android.gms.maps.CameraUpdateFactory; //导入依赖的package包/类
/**
 * Called when the Animate To "Go To Analog Stick" button is clicked.
 */
public void onGoToVrController(View view) {

    if (!checkReady()) {
        return;
    }

    changeCamera(CameraUpdateFactory.newCameraPosition(vrControllerCameraPos), new CancelableCallback() {
        @Override
        public void onFinish() {
            Toast.makeText(getBaseContext(), "Animation to Analog Stick complete", Toast.LENGTH_SHORT)
                    .show();
        }

        @Override
        public void onCancel() {
            Toast.makeText(getBaseContext(), "Animation to Analog Stick canceled", Toast.LENGTH_SHORT)
                    .show();
        }
    });
}
 
开发者ID:AviralGarg1993,项目名称:VR-One,代码行数:24,代码来源:MapActivity.java

示例14: setUpMap

import com.google.android.gms.maps.CameraUpdateFactory; //导入依赖的package包/类
@SuppressWarnings({"MissingPermission"})
private void setUpMap() {
    mMap.setMyLocationEnabled(true);
    //mMap.setPadding(0, ConversionUtil.dpToPx(68, getResources()), 0, 0);
    mMap.getUiSettings().setMyLocationButtonEnabled(true);


    //Add circle and marker
    int strokeColor = ContextCompat.getColor(getActivity(), R.color.map_circle_stroke);
    int shadeColor = ContextCompat.getColor(getActivity(), R.color.map_circle_shade);
    LatLng latLng = ConversionUtil.placeToLatLng(mReminder.getPlace());
    mMap.addCircle(new CircleOptions()
            .center(latLng)
            .radius(mReminder.getPlace().getRadius())
            .fillColor(shadeColor)
            .strokeColor(strokeColor)
            .strokeWidth(2));
    mMap.addMarker(new MarkerOptions().position(latLng));

    //Move camera
    //mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latlng, 15), 1000, null);  //Zoom level 15 = Streets, 1000ms animation
    CameraPosition cameraPos = new CameraPosition.Builder().tilt(60).target(latLng).zoom(15).build();
    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPos), 1000, null);
}
 
开发者ID:abicelis,项目名称:Remindy,代码行数:25,代码来源:LocationBasedReminderDetailFragment.java

示例15: onMapReady

import com.google.android.gms.maps.CameraUpdateFactory; //导入依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
    map = googleMap;
    map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
    map.getUiSettings().setMyLocationButtonEnabled(true);
    if (ActivityCompat.checkSelfPermission(this.getContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this.getContext(), android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
        map.setMyLocationEnabled(true);

    }
    LatLng laLatLng = new LatLng(34.040011, -118.259419);
    map.moveCamera(CameraUpdateFactory.newLatLng(laLatLng));
    map.moveCamera(CameraUpdateFactory.zoomTo(15));

    map.setOnMapClickListener(new GoogleMap.OnMapClickListener() {

        @Override
        public void onMapClick(LatLng point) {
            // TODO Auto-generated method stub
            //lstLatLngs.add(point);
            map.clear();
            map.addMarker(new MarkerOptions().position(point));
            mCoordinateOfRestriction = point.toString();

        }
    });
}
 
开发者ID:curbmap,项目名称:curbmap-android,代码行数:27,代码来源:HomeFragment.java


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