Java 类com.google.android.gms.maps.CameraUpdateFactory 实例源码

项目:nirbhaya    文件:NirbhayaMapsActivity.java   
/**
 * 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));

}
项目:FiveMinsMore    文件:MapUtils.java   
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();
    }
}
项目:TrackIn-Android-Application    文件:cordmap.java   
@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)));
    }
项目:TFG-SmartU-La-red-social    文件:FragmentMapa.java   
@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));
    }
}
项目:ExtraMapUtils    文件:MapUtils.java   
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);
                }

            });
        }
    });


}
项目:Find-It-Location-Finder    文件:MapsActivity.java   
@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);
}
项目:FiveMinsMore    文件:MapsActivity.java   
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));
    }
}
项目:Android-Programming-BigNerd    文件:LocatrFragment.java   
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);
}
项目:Protestr    文件:CreateEventActivity.java   
@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
                }
            });
}
项目:FordOpenXCHackathon    文件:MainActivity.java   
@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));
    }

}
项目:hubISM    文件:Campus_Map.java   
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));
    }
}
项目:MyFlightbookAndroid    文件:ActFlightMap.java   
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));
    }
}
项目:VR-One    文件:MapActivity.java   
/**
 * 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();
        }
    });
}
项目:Remindy    文件:LocationBasedReminderDetailFragment.java   
@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);
}
项目:curbmap-android    文件:HomeFragment.java   
@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();

        }
    });
}
项目:go-jay    文件:MainActivity.java   
@Override
public void onSuggestResult(final Place place, final AutoCompleteTextView act) {
    final LatLng placelatlng=place.getLatLng();
    if (!isNavigationReady() && (addr_from.getText().length() < 1 || addr_to.getText().length() < 1))
        gmaps.animateCamera(CameraUpdateFactory.newLatLng(place.getLatLng()), 1000, new GoogleMap.CancelableCallback(){
                @Override
                public void onFinish() {
                    setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
                }

                @Override
                public void onCancel() {
                    setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
                }
            });
    else setAddrValue(act == addr_from ?addr_from: addr_to, placelatlng);
}
项目:iSPY    文件:MyLocation.java   
private void moveMap() {
    //String to display current latitude and longitude
    msg = latitude + ", "+longitude;
    add=msg;
    setPreference(add);


    getCompleteAddressString(latitude,longitude);
    //Creating a LatLng Object to store Coordinates
    LatLng latLng = new LatLng(latitude, longitude);

    //Adding marker to map
    mMap.addMarker(new MarkerOptions()
            .position(latLng) //setting position
            .draggable(true) //Making the marker draggable
            .title("Current Location")); //Adding a title
    //Moving the camera
    mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));

    //Animating the camera
    mMap.animateCamera(CameraUpdateFactory.zoomTo(15));

    //Displaying current coordinates in toast
    Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
}
项目:Overkill    文件:MapsActivity.java   
/**
 * 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.setMyLocationEnabled(true);
    mMap.setTrafficEnabled(true);

    // move to the center of Vietnam
    mMap.animateCamera(CameraUpdateFactory.zoomTo(18), 2000, null);
    CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(new LatLng(10.7771649,106.6953986))
            .zoom(18)
            .bearing(90)
            .tilt(30)
            .build();
    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
项目:Dispatch    文件:MainActivity.java   
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);
    }
项目:HabitUp    文件:MapsActivity.java   
@Override
public void onLocationChanged(Location location)
{
    mLastLocation = location;
    if (mCurrLocationMarker != null) {
        mCurrLocationMarker.remove();
    }

    //Place current location marker
    LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
    MarkerOptions markerOptions = new MarkerOptions();
    markerOptions.position(latLng);
    markerOptions.title("Current Position");
    markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
    mCurrLocationMarker = mGoogleMap.addMarker(markerOptions);

    //move map camera
    mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng,11));

}
项目:Crimson    文件:SearchClinics.java   
@Override
public void onLocationChanged(Location location) {

    currentLatitude = location.getLatitude();
    currentLongitude = location.getLongitude();

    //Toast.makeText(this, currentLatitude + " WORKS " + currentLongitude + "", Toast.LENGTH_LONG).show();

    LatLng latLng = new LatLng(currentLatitude, currentLongitude);
    googleMap.addMarker(new MarkerOptions().position(latLng));
    googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));
    googleMap.animateCamera(CameraUpdateFactory.zoomIn());
    googleMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);

    getNearByClinics(currentLongitude, currentLatitude);

}
项目:RoadLab-Pro    文件:BaseStartMeasurementMapFragment.java   
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();
    }
}
项目:cat-is-a-dog    文件:AddHabitEventActivity.java   
/**
 * 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));
    }
}
项目:WalkGraph    文件:MapFragmentImpl.java   
/**
 * 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);
}
项目:Android-Wear-Projects    文件:MapsActivity.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    // Map is ready to be used.
    mMap = googleMap;

    // Set the long click listener as a way to exit the map.
    mMap.setOnMapLongClickListener(this);
    mMap.setOnMapClickListener(this);

    if (checkPermission()){
        mMap.setMyLocationEnabled(true);
    }else{

    }


    // Add a marker in Sydney, Australia and move the camera.
    LatLng sydney = new LatLng(-34, 151);
    mMap.setInfoWindowAdapter(new WearInfoWindowAdapter(getLayoutInflater(), mMemories));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
项目:CIA    文件:ViewEventsMapActivity.java   
/**
 * 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));
    }
}
项目:RoadLab-Pro    文件:BaseMapFragment.java   
private void setCurrentLocation(Location location) {
    if (location == null) {
        return;
    }
    final LatLng latLng = getMyLocation(location);
    if (goToLocation) {
        map.animateCamera(CameraUpdateFactory.
                newLatLngZoom(latLng, Constants.DEFAULT_LOCATION_FOUND_CAMERA_ZOOM));
        if (firstLocationRefresh) {
            goToLocation = false;
            firstLocationRefresh = false;
        }
    }
    refreshMyLocation(latLng);
}
项目:Bee-Analyzer    文件:GateAnalysis.java   
private void setUpMap()
{
    LatLng localLatLng = new LatLng(41.104889999999997D, 29.027756D);
    this.mMap.moveCamera(CameraUpdateFactory.newLatLng(localLatLng));
    this.mMap.animateCamera(CameraUpdateFactory.zoomTo(15.0F));
    if (this.mMap == null)
        this.mMap = ((MapFragment)getFragmentManager().findFragmentById(R.id.gateMap)).getMap();
    if (this.mMap != null)
    {
        PolylineOptions localPolylineOptions = new PolylineOptions().add(new LatLng(41.106655000000003D, 29.014520999999998D)).add(new LatLng(41.108691999999998D, 29.021429999999999D)).add(new LatLng(41.108967D, 29.029983999999999D)).add(new LatLng(41.111206000000003D, 29.037043000000001D)).add(new LatLng(41.099578999999999D, 29.038195999999999D)).add(new LatLng(41.097768000000002D, 29.022210000000001D)).add(new LatLng(41.106655000000003D, 29.014520999999998D)).width(5.0F).color(-16776961).geodesic(true);
        this.mMap.addPolyline(localPolylineOptions);
    }
}
项目:TFG-SmartU-La-red-social    文件:FragmentMapaProyecto.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    //Inicializo el mapa
    MapsInitializer.initialize(getContext());
    mMap = googleMap;

    //Si tengo proyectos los muestro en el mapa
    if (proyecto.getCoordenadas().compareTo("") != 0) {
        String[] coordenadas = proyecto.getCoordenadas().split(",");
        double lat = Double.parseDouble(coordenadas[0]);
        double lon = Double.parseDouble(coordenadas[1]);
        posicionProyecto = new LatLng(lat, lon);
        MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.title(proyecto.getNombre());
        //Pongo la descripción en el infowindow solo con 10 caracteres
        if (proyecto.getDescripcion().length() > 50)
            markerOptions.snippet(proyecto.getDescripcion().substring(0, 50));
        else
            markerOptions.snippet(proyecto.getDescripcion());
        markerOptions.position(posicionProyecto);
        mMap.addMarker(markerOptions);
    }

    // Movemos la camara a la posicion del usuario
    if (miPosicion != null)
        mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(miPosicion, 3));

}
项目:MapaDeIgarassuAdmin    文件:HomeActivity.java   
@Override
public void onMapReady(GoogleMap googleMap) {

    GoogleMapsModel.setMap(googleMap);

     /*Verificação de tipos de mapa*/
    if (Constants.MAP_TYPE_HYBRID == SharedPreferencesUtil.getTypeMaps(this)) {
        GoogleMapsModel.getMap().setMapType(Constants.MAP_TYPE_HYBRID);
    } else {
        GoogleMapsModel.getMap().setMapType(Constants.MAP_TYPE_NORMAL);
    }

    invokeAddMarkerMapOther.onAddMarkerFirebase(); //adicionando os marcados diretamente do firebase
    GoogleMapsModel.getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(Constants.CENTER_LOCATION, 16)); /*Centro do mapa*/
    /*Botões de Zoom*/
    GoogleMapsModel.getMap().getUiSettings().setZoomControlsEnabled(true);

    infoWindow();

     /*Listener de cada marker*/
    GoogleMapsModel.getMap().setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
        @Override
        public void onInfoWindowClick(Marker marker) {

            DataBaseUtil dataBaseUtil = new DataBaseUtil(context); /*Instância da base de dados local*/

            String name = marker.getTitle();
            LocationModel locationModel = dataBaseUtil.getLocation(name);

            if (name.equals(locationModel.getName())) {
                AlertDialogMessage alertDialogMessage = new AlertDialogMessage();
                alertDialogMessage.alertDialogMarker(context, locationModel.getId(),
                        locationModel.getName(), locationModel.getAddress(),
                        locationModel.getDescription(), locationModel.getLatitude(), locationModel.getLongitude());
            }
        }

    });

}
项目:FiveMinsMore    文件:MapsManager.java   
@Override
public void onMarkerDragEnd(Marker marker) {
    LatLng latLng = marker.getPosition();
    marker.setSnippet(ProjFuncs.latLng2DString(latLng, false));
    marker.showInfoWindow();
    mMaps.get(MAP_CODE_MAIN).animateCamera(CameraUpdateFactory.newLatLng(latLng));
}
项目:ExtraMapUtils    文件:MapUtils.java   
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));
}
项目:ExtraMapUtils    文件:MapUtils.java   
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));
}
项目:today-menu-android    文件:RestaurantsMapFragment.java   
public void zoomToCurrentPosition() {
    if (mMap == null) {
        return;
    }
    LatLng latLng = new LatLng(Prefs.LastLatitude.getDouble(), Prefs.LastLongitude.getDouble());
    CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 16);
    mMap.animateCamera(cameraUpdate);
}
项目:Nibo    文件:BaseNiboFragment.java   
protected void initmap() {
    SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    mLocationRepository = new LocationRepository(getActivity(), mGoogleApiClient);

    mLocationRepository.getLocationObservable()
            .subscribe(new Consumer<Location>() {
                @Override
                public void accept(@NonNull Location location) throws Exception {
                    CameraPosition cameraPosition = new CameraPosition.Builder()
                            .target(new LatLng(location.getLatitude(), location.getLongitude()))
                            .zoom(15)
                            .build();
                    mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
                    handleLocationRetrieval(location);
                    extractGeocode(location.getLatitude(), location.getLongitude());

                }
            }, new Consumer<Throwable>() {
                @Override
                public void accept(@NonNull Throwable throwable) throws Exception {
                    throwable.printStackTrace();
                }
            });


}
项目:SkateSpot    文件:MapsActivity.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    g = new GPSTracker(getApplicationContext());
    l = g.getLocation();
    me = new LatLng(l.getLatitude(), l.getLongitude());
    mMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(me, 14, 45, 0)));
    mMap.setPadding(0, 0, 0, 1720);
}
项目:Taxi-App-Android-XML    文件:MyTrip.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    boolean success = googleMap.setMapStyle(new MapStyleOptions(getResources()
            .getString(R.string.style_json)));

    if (!success) {
        Log.e("Style", "Style parsing failed.");
    }
    LatLng jakarta = new LatLng(-6.232812, 106.820933);
    mMap.addMarker(new MarkerOptions().position(jakarta).icon(BitmapDescriptorFactory.fromBitmap(getBitmapFromView("Set Pickup Location", R.drawable.dot_pickup))));
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(jakarta, 15f));
}
项目:Android-Developer-Path    文件:Main2Activity.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    LatLng location = new LatLng(x, y);
    mMap.addMarker(
            new MarkerOptions().position(location)
                    .title("Marker in Sydney"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(location));
}
项目:Android-Developer-Path    文件:MapsActivity.java   
/**
 * 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
    LatLng sydney = new LatLng(-34, 151);
    mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
    mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
项目:iSPY    文件:ShortestDistance.java   
private void addCameraToMap(LatLng latLng){
    CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(latLng)
            .zoom(8)
            .build();
    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}