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

项目: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));

}
项目:android-googlemaps    文件:MapFragment.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    gMap =googleMap;
    // Add a marker in Sydney and move the camera
    LatLng sucre = new LatLng(-19.040179078634807, -65.25621296313443);

    MarkerOptions marker = new MarkerOptions()
            .position(sucre)
            .title("Bienvenidos a la CCBOL2017")
            .draggable(true);

    gMap.addMarker(marker);

    CameraPosition camera = new CameraPosition.Builder()
            .target(sucre)
            .zoom(18)  //limite ->21
            .bearing(0) // 0 - 365
            .tilt(45) // limite ->90
            .build();

    gMap.animateCamera(CameraUpdateFactory.newCameraPosition(camera));
}
项目:MuslimMateAndroid    文件:MosquesActivity.java   
@Override
public void onLocationChanged(Location location) {
    if (location.getLatitude() != 0 || location.getLongitude() != 0) {
        setFusedLatitude(location.getLatitude());
        setFusedLongitude(location.getLongitude());
        stopFusedLocation();
        CameraPosition oldPos = googleMap.getCameraPosition();
        CameraPosition pos = CameraPosition.builder(oldPos)
                .target(getPosition())
                .zoom(zoom)
                .build();
        googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(pos));

        Marker marker = googleMap.addMarker(new MarkerOptions()
                .position(getPosition())
                .title("My Location").icon(BitmapDescriptorFactory.fromResource(R.drawable.placeholder)));


        AsyncTask placesAsync = new Places().execute(getPosition());

    }

}
项目:puremadrid    文件:MyMapFragment.java   
@Override
protected Integer doInBackground(String... params) {
    android.location.Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
    int times = 0;
    while (location == null && times < 20){
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {

        }
        location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
        times++;
    }
    if (location != null) {
        final CameraPosition position = new CameraPosition.Builder()
                .target(new LatLng(location.getLatitude(), location.getLongitude()))
                .zoom(14.0f).build();
        getActivity().runOnUiThread(new Runnable() {
            public void run() {
                map.animateCamera(CameraUpdateFactory.newCameraPosition(position));
            }
        });
    }
    return null;
}
项目:FiveMinsMore    文件:MapsActivity.java   
@Override
protected void onStop() {
    super.onStop();

    if (mGoogleApiClient.isConnected()) {
        mGoogleApiClient.disconnect();
    }

    SharedPreferences prefs = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
    SharedPreferences.Editor editor = prefs.edit();
    editor.putBoolean("isTracking", mTrackingBtn.isSelected());
    if (mMap != null) {
        CameraPosition cameraPosition = mMap.getCameraPosition();
        editor.putFloat("cameraLat", (float) cameraPosition.target.latitude);
        editor.putFloat("cameraLon", (float) cameraPosition.target.longitude);
        editor.putFloat("cameraZoom", cameraPosition.zoom);
    }
    editor.putString("poiFile", poiFile);
    editor.putString("mapFile", mapFile);
    editor.putString("themeFile", themeFile);
    editor.putStringSet("gpxFiles", mGpxManager.getGpxList());
    editor.putInt("coorSetting", CoorSysList.coorSetting);
    editor.apply(); //important, otherwise it wouldn't save.
}
项目:Overkill    文件:MapsActivity2.java   
private void moveToPosition() {
    // add a marker
    LatLng wantToGoTo = start;
    mMap.clear();
    mMap.addMarker(new MarkerOptions().position(wantToGoTo).title(info)
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.personstanding)));

    // create an animation for map while moving to this location
    mMap.animateCamera(CameraUpdateFactory.zoomTo(18), 2000, null);
    CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(wantToGoTo)
            .zoom(18)
            .bearing(90)
            .tilt(30)
            .build();
    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

}
项目: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));
}
项目: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
                }
            });
}
项目: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);
}
项目:GoogleMapsLayout-Android    文件:MapLayout.java   
/**
 * 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);
}
项目:referendum_1o_android    文件:VoteFragment.java   
public void startLocation() {
    if (ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, LOCATION_PERMISSION_ID);
    } else {
        Location mLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);

        if (mLocation == null) {
            showGpsDialog();
        } else {
            mGoogleMap.setMyLocationEnabled(true);

            //Move Camera to myLocation
            CameraPosition cameraPosition = new CameraPosition.Builder()
                    .target(new LatLng(mLocation.getLatitude(), mLocation.getLongitude()))
                    .zoom(13)
                    .build();

            mGoogleMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
        }
    }
}
项目:referendum_1o_android    文件:GridClusteringStrategy.java   
@Override
public void onCameraChange(CameraPosition cameraPosition) {
    oldZoom = zoom;
    zoom = Math.round(cameraPosition.zoom);
    double clusterSize = calculateClusterSize(zoom);
    if (this.clusterSize != clusterSize) {
        this.clusterSize = clusterSize;
        recalculate();
    } else if (addMarkersDynamically) {
        addMarkersInVisibleRegion();
    }
    if (DEBUG_GRID) {
        if (debugHelper == null) {
            debugHelper = new DebugHelper();
        }
        debugHelper.drawDebugGrid(map, clusterSize);
    }
}
项目:mocket_android_demo    文件:MapsActivity.java   
@Override
public void onLocationChanged(Location location) {

  //place marker at current position
  //mGoogleMap.clear();
  if (currLocationMarker != null) {
    currLocationMarker.remove();
  }
  latLng = new LatLng(location.getLatitude(), location.getLongitude());
  MarkerOptions markerOptions = new MarkerOptions();
  markerOptions.position(latLng);
  markerOptions.title(getString(R.string.current_position));
  markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
  currLocationMarker = mGoogleMap.addMarker(markerOptions);

  //zoom to current position:
  CameraPosition cameraPosition = new CameraPosition.Builder()
    .target(latLng).zoom(14).build();

  mGoogleMap.animateCamera(CameraUpdateFactory
    .newCameraPosition(cameraPosition));

  mMocketClient.pushLatLngToServer(latLng);
}
项目:AndiCar    文件:GPSTrackMap.java   
private void setUpMap() {
    if (!loadTrackFiles) {
        return;
    }

    if (!loadTrackAndBounds()) {
        Utils.showNotReportableErrorDialog(this, getString(R.string.gen_error), mErrMsg);
        return;
    }

    mMap.addPolyline(mTrackLine).setWidth(trackLineWidth);
    mMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
        @Override
        public void onCameraChange(CameraPosition arg0) {
            // Move camera.
            mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(mTrackBoundBuilder.build(), 100));
            // Remove listener to prevent position reset on camera move.
            mMap.setOnCameraChangeListener(null);
        }
    });
}
项目:Nibo    文件:NiboPickerFragment.java   
protected void addSingleMarkerToMap(LatLng latLng) {
    if (mMap != null) {
        if (mCurrentMapMarker != null) {
            mCurrentMapMarker.remove();
        }
        CameraPosition cameraPosition =
                new CameraPosition.Builder().target(latLng)
                        .zoom(getDefaultZoom())
                        .build();
        hasWiderZoom = false;
        mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
        mCurrentMapMarker = addMarker(latLng);
        mMap.setOnMarkerDragListener(this);
        extractGeocode(latLng.latitude, latLng.longitude);
    }
}
项目:Nibo    文件:NiboOriginDestinationPickerFragment.java   
void addOriginMarker(LatLng latLng) {
    if (mMap != null) {
        if (mOriginMapMarker != null) {
            mOriginMapMarker.remove();
            mOriginMapMarker = null;
        }
        CameraPosition cameraPosition =
                new CameraPosition.Builder().target(latLng)
                        .zoom(getDefaultZoom())
                        .build();

        hasWiderZoom = false;
        mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

        if (mOriginMarkerPinIconRes != DEFAULT_MARKER_ICON_RES) {
            mOriginMapMarker = addMarker(latLng, mOriginMarkerPinIconRes);
        } else {
            mOriginMapMarker = addMarker(latLng);
        }


        mMap.setOnMarkerDragListener(this);

        showBothMarkersAndGetDirections();
    }
}
项目:Appmatic-Android    文件:ContactFragment.java   
@Override
public CameraPosition getCameraPositionAtLocation() {
    final double cameraOffset;

    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
        cameraOffset = 0.0032;
    else
        cameraOffset = 0;

    return new CameraPosition.Builder()
            .target(new LatLng(contact.getLatitude() - cameraOffset, contact.getLongitude()))
            .zoom(16f)
            .bearing(0)
            .tilt(45f)
            .build();
}
项目:Privy    文件:PrivyMapsFragment.java   
private void getMyCurrentLocation() {
    myLocationData = getCurrentLocation();
    if (myLocationData != null) {

        float bearing = 0;
        if(myLocationData.hasBearing())
            bearing = myLocationData.getBearing();

        MY_LOCATION_CAMERA_POS = new CameraPosition.Builder()
                .target(new LatLng(myLocationData.getLatitude(), myLocationData.getLongitude()))
                .zoom(zoom)
                .bearing(bearing)
                .tilt(25)
                .build();

        //animate camera
        moveCameraToMyLocation();
        addMarkers();

        Log.d(DEBUG, new LatLng(myLocationData.getLatitude(), myLocationData.getLongitude()).toString());
    } else {
        Log.d(DEBUG, "Can't retrieve location at the moment.");
        if (!checkGPSon())
            promptToEnableGPS();
    }
}
项目:gaso    文件:MapGasoFragment.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    this.googleMap = googleMap;
    isMapReady = true;
    isNotificationPendent = true;
    markers.clear();

    // latitude and longitude,
    double latitude = -10.918546;
    double longitude = -37.060854;

    location = locationHelper.getLastKnownLocation();
    if(location!=null) {
        latitude = location.getLat();
        longitude = location.getLng();
    }

    CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(new LatLng(latitude, longitude)).zoom(12).build();
    googleMap.animateCamera(CameraUpdateFactory
            .newCameraPosition(cameraPosition));

    addMarkers();
    setUpMap();

}
项目:GeoShare_Android    文件:MapsFragment.java   
@Override
public void onLocationChanged(Location location) {
    if (isTracking) {
        //Will only move the camera if the users current location is in focus
        CameraPosition cameraPosition = new CameraPosition.Builder().target(new LatLng(location.getLatitude(), location.getLongitude())).zoom(standardZoomLevel).build();
        googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    }

    listenerLocation = location;

    LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());

    if (myLocation != null) myLocation.setPosition(latLng);

    /* GET NUMBER OF FRIENDS WITHIN A GIVEN RADIUS */
    nearbyFriends();
    nearbyRadius(latLng);
    //accuracyCircle(latLng, location.getAccuracy());
}
项目:react-native-maps    文件:PPTGoogleMapManager.java   
/**
 * Called repeatedly during any animations or gestures on the map (or once, if the camera is
 * explicitly set). This may not be called for all intermediate camera positions. It is always
 * called for the final position of an animation or gesture.
 *
 * @param cameraPosition
 */
@Override
public void onCameraChange(CameraPosition cameraPosition) {
    WritableMap event = Arguments.createMap();
    WritableMap data = Arguments.createMap();

    data.putDouble("latitude", cameraPosition.target.latitude);
    data.putDouble("longitude", cameraPosition.target.longitude);
    data.putDouble("zoom", cameraPosition.zoom);

    event.putString("event", "didChangeCameraPosition");
    event.putMap("data", data);

    reactContext.getJSModule(RCTEventEmitter.class).receiveEvent(
            mapView.getId(),
            "topChange",
            event
    );
}
项目:Stayfit    文件:MapLoadFragment.java   
@Override
public void onLocationChanged(Location location) {
    // Add a marker in Sydney and move the camera
    LatLng sydney = new LatLng(AskLocationActivity.address1.getLatitude(), AskLocationActivity.address1.getLongitude());
    mMap.addMarker(new MarkerOptions().position(sydney).title(AskLocationActivity.place1));
   // mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
    //move camera when location changed
    LatLng latLng_Now = new LatLng(location.getLatitude(), location.getLongitude());
    CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(sydney)      // Sets the center of the map to LatLng (refer to previous snippet)
            .zoom(17)                   // Sets the zoom
            .bearing(90)                // Sets the orientation of the camera to east
            .tilt(45)                   // Sets the tilt of the camera to 45 degrees
            .build();                   // Creates a CameraPosition from the builder
    mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    if (latLng_Prev == null) {
        latLng_Prev = latLng_Now;
    }
    //draw line between two locations:
   /* Polyline line = mMap.addPolyline(new PolylineOptions()
            .add(latLng_Prev, latLng_Now)
            .width(5)
            .color(Color.RED));
    latLng_Prev = latLng_Now;*/
}
项目:UNCmorfi    文件:MapFragment.java   
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;

    mMap.addMarker(new MarkerOptions()
            .position(CENTRAL)
            .title("Sucursal Central"));

    mMap.addMarker(new MarkerOptions()
            .position(BELGRANO)
            .title("Sucursal Belgrano"));

    CameraPosition cameraPosition = CameraPosition.builder()
            .target(CENTER)
            .zoom(14)
            .build();

    mMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
项目:YalantisInternship    文件:MapsActivity.java   
/**
 * Manipulates the map once available.
 * Here we just put camera to Yalantis office position
 * But we can call ContentProvider and populate map with markers...
 */
@Override
public void onMapReady(GoogleMap googleMap) {
    // Add a marker in Dnipropetrovsk (Yalantis office) and move the camera
    LatLng dnipr = new LatLng(48.4517867, 35.0669826);
    int defaultZoom = 12;

    googleMap.addMarker(new MarkerOptions().position(dnipr).title(getString(R.string.map_marker)));

    CameraPosition cameraPosition = CameraPosition.builder()
            .target(dnipr)
            .zoom(defaultZoom)
            .build();

    googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
项目:YalantisInternship    文件:MapsActivity.java   
@Override
public void showMarker(Intent intent) {
    TaskRealm taskRealm = intent.getParcelableExtra(TaskRealm.TASK_EXTRA);

    if (taskRealm != null) {
        LatLng position = new LatLng(taskRealm.getLatitude(), taskRealm.getLongitude());

        mGoogleMap.addMarker(new MarkerOptions().position(position)
                .title(taskRealm.getTitle())
                .snippet(taskRealm.getDescription()));

        CameraPosition cameraPosition = CameraPosition.builder()
                .target(position)
                .zoom(ZOOM_DEFAULT)
                .build();

        mGoogleMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    }

}
项目:Forage    文件:CacheDetailActivity.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    googleMap.getUiSettings().setMapToolbarEnabled(false);

    // Add marker for geocache and move camera
    LatLng markerPos = new LatLng(location.getLatitude(), location.getLongitude());
    googleMap.addMarker(new MarkerOptions()
            .position(markerPos));

    CameraPosition cameraPosition = new CameraPosition.Builder()
            .target(markerPos)
            .zoom(13).build();

    googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

}
项目:EarthquakeSurvival    文件:MapviewFragment.java   
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    if (key.equals(getString(R.string.sharedprefs_key_magnitude))) {
        getLoaderManager().restartLoader(CURSOR_LOADER_ID, null, this);
    } else if (key.equals(getString(R.string.sharedprefs_key_latitude)) ||
            key.equals(getString(R.string.sharedprefs_key_longitude))) {

        if (mGoogleMap != null) {
            mCameraPosition = CameraPosition.builder()
                    .target(LocationUtils.getLocation(getContext()))
                    .zoom(LocationUtils.CAMERA_DEFAULT_ZOOM)
                    .build();

            mGoogleMap.moveCamera(CameraUpdateFactory.newCameraPosition(mCameraPosition));
        }
    } else if (key.equals(getString(R.string.sharedprefs_key_faultlines))) {
        showFaultlines();
    }
}
项目:FastFoodFinder    文件:MainMapFragment.java   
public SupportMapFragment inflateSupportMapFragment() {
    FragmentManager fragmentManager = getChildFragmentManager();
    SupportMapFragment mapFragment = (SupportMapFragment) fragmentManager.findFragmentById(R.id.maps_container);
    if (mapFragment == null) {
        CameraPosition cameraPosition = CameraPosition.builder()
                .target(new LatLng(10.7473821, 106.6805755))
                .zoom(16)
                .build();
        GoogleMapOptions options = new GoogleMapOptions();
        options.mapType(GoogleMap.MAP_TYPE_NORMAL)
                .camera(cameraPosition)
                .compassEnabled(true)
                .rotateGesturesEnabled(true)
                .zoomGesturesEnabled(true)
                .tiltGesturesEnabled(true);
        mapFragment = SupportMapFragment.newInstance(options);
        fragmentManager.beginTransaction().replace(R.id.map_placeholder, mapFragment).commit();
        fragmentManager.executePendingTransactions();
    }

    return mapFragment;
}
项目:blunch_android    文件:MenusLocationActivity.java   
@Override
public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;
    mMap.setOnMyLocationButtonClickListener(this);
    //mMap.setOnInfoWindowClickListener(this);
    mMap.setOnMarkerClickListener(this);

    if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
        mMap.setMyLocationEnabled(true);
    } else {
        // Show rationale and request permission.
    }

    //we search for the fib
    LatLng BCN = getLocationFromAddress("Barcelona");
    if (BCN != null) {
        CameraPosition cameraPosition = new CameraPosition.Builder()
                .target(BCN)      // Sets the center to BCN
                .zoom(10)         // we set the zoom
                .build();
        mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 5000, null);
    }
    situaMenus();
}
项目:PhoneChat    文件:PluginMap.java   
/**
 * Set angle of the map view
 * @param args
 * @param callbackContext
 * @throws JSONException 
 */
@SuppressWarnings("unused")
private void setTilt(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
  float tilt = -1;
  tilt = (float) args.getDouble(1);

  if (tilt >= 0 && tilt <= 90) {
    CameraPosition currentPos = map.getCameraPosition();
    CameraPosition newPosition = new CameraPosition.Builder()
        .target(currentPos.target).bearing(currentPos.bearing)
        .zoom(currentPos.zoom).tilt(tilt).build();
    myMoveCamera(newPosition, callbackContext);
  } else {
    callbackContext.error("Invalid tilt angle(" + tilt + ")");
  }
}
项目:PhoneChat    文件:PluginMap.java   
/**
 * Return the current position of the camera
 * @param args
 * @param callbackContext
 * @throws JSONException 
 */
@SuppressWarnings("unused")
private void getCameraPosition(final JSONArray args, final CallbackContext callbackContext) throws JSONException {
  CameraPosition camera = map.getCameraPosition();
  JSONObject json = new JSONObject();
  JSONObject latlng = new JSONObject();
  latlng.put("lat", camera.target.latitude);
  latlng.put("lng", camera.target.longitude);
  json.put("target", latlng);
  json.put("zoom", camera.zoom);
  json.put("tilt", camera.tilt);
  json.put("bearing", camera.bearing);
  json.put("hashCode", camera.hashCode());

  callbackContext.success(json);
}
项目:PhoneChat    文件:GoogleMaps.java   
/**
 * Notify the myLocationChange event to JS
 */
@Override
public void onCameraChange(CameraPosition position) {
  JSONObject params = new JSONObject();
  String jsonStr = "";
  try {
    JSONObject target = new JSONObject();
    target.put("lat", position.target.latitude);
    target.put("lng", position.target.longitude);
    params.put("target", target);
    params.put("hashCode", position.hashCode());
    params.put("bearing", position.bearing);
    params.put("tilt", position.tilt);
    params.put("zoom", position.zoom);
    jsonStr = params.toString();
  } catch (JSONException e) {
    e.printStackTrace();
  }
  webView.loadUrl("javascript:plugin.google.maps.Map._onCameraEvent('camera_change', " + jsonStr + ")");
}
项目:Freifunk-App    文件:NodeClusterManager.java   
/**
 * Might re-cluster.
 *
 * @param cameraPosition
 */
@Override
public void onCameraChange(CameraPosition cameraPosition) {
    if (mRenderer instanceof GoogleMap.OnCameraChangeListener) {
        ((GoogleMap.OnCameraChangeListener) mRenderer).onCameraChange(cameraPosition);
    }

    if (mAlgorithm instanceof GoogleMap.OnCameraChangeListener) {
        ((GoogleMap.OnCameraChangeListener) mAlgorithm).onCameraChange(cameraPosition);
    }

    if (mShowOnlyVisibleArea) {
        // algorithm will decide if it is need to recompute clusters
        cluster();
    } else if (mPreviousCameraPosition == null || mPreviousCameraPosition.zoom != cameraPosition.zoom) {
        // Don't re-compute clusters if the map has just been panned/tilted/rotated.
        mPreviousCameraPosition = mMap.getCameraPosition();
        cluster();
    }
}
项目:MapViewPager    文件:MapViewPager.java   
private void populateMulti(final MultiAdapter adapter) {
    map.clear();
    allMarkers = new LinkedList<>();
    for (int page = 0; page < adapter.getCount(); page++) {
        LinkedList<Marker> pageMarkers = new LinkedList<>();
        if (adapter.getCameraPositions(page) != null) {
            for (int i = 0; i < adapter.getCameraPositions(page).size(); i++) {
                CameraPosition cp = adapter.getCameraPositions(page).get(i);
                if (cp != null) {
                    MarkerOptions mo = createMarkerOptions(cp, adapter.getMarkerTitle(page, i));
                    pageMarkers.add(map.addMarker(mo));
                }
                else pageMarkers.add(null);
            }
        }
        allMarkers.add(pageMarkers);
    }
    map.setOnMarkerClickListener(createMarkerClickListenerMulti(adapter));
    initDefaultPositions(adapter);
}
项目:MapViewPager    文件:MapViewPager.java   
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);
}
项目:calchoochoo    文件:MapSearchFragment.java   
private Action1<RxMessage> handleRxMessages() {
  return new Action1<RxMessage>() {
    @Override
    public void call(RxMessage rxMessage) {
      if (rxMessage.isMessageValidFor(RxMessageKeys.FAB_CLICKED)) {
        LatLng myLatLng = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude());
        CameraPosition cameraPosition = new CameraPosition.Builder().zoom(13).target(myLatLng).build();
        googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
      } else if (rxMessage.isMessageValidFor(RxMessageKeys.MY_LOCATION_UPDATE) || rxMessage.isMessageValidFor(RxMessageKeys.MY_LOCATION)) {
        Location location = ((RxMessageLocation) rxMessage).getMessage();
        if (location != null) {
          setMyLocationMarker(location);
        }
      }
    }
  };
}
项目:RxGoogleMapsBinding    文件:CameraPositionChangeOnSubscribe.java   
@Override public void call(final Subscriber<? super CameraPosition> subscriber) {
  MainThreadSubscription.verifyMainThread();

  GoogleMap.OnCameraChangeListener listener = new GoogleMap.OnCameraChangeListener() {
    @Override public void onCameraChange(CameraPosition cameraPosition) {
      if (!subscriber.isUnsubscribed()) {
        subscriber.onNext(cameraPosition);
      }
    }
  };
  map.setOnCameraChangeListener(listener);

  subscriber.add(new MainThreadSubscription() {
    @Override protected void onUnsubscribe() {
      map.setOnCameraChangeListener(null);
    }
  });
}
项目:TWD97_change_to_WGS    文件:ParkingMain.java   
@Override
public void onClick(View v) {
    BuildParkingCamera();
    Bundle bundle=getIntent().getExtras();
    temp=bundle.getInt("Park_ID");
    //Toast.makeText(ParkingMain.this,temp+"",Toast.LENGTH_SHORT).show();
    BuildMapView();

    map=((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
    LatLng latLngtemp=new LatLng(25.010611, 121.464115);
    CameraPosition currentPlace = new CameraPosition.Builder()
            .target(latLngtemp)
            .bearing(0)
            .tilt(65.5f)
            .zoom(17)
            .build();
    //added a tilt[.tilt(65.5f)] value so the map will rotate in 3D.
    map.moveCamera(CameraUpdateFactory.newCameraPosition(currentPlace));
    map.animateCamera(CameraUpdateFactory.newLatLngZoom(latLngtemp,17));
    MarkerOptions markerOptions=new MarkerOptions();
    markerOptions.position(latLngtemp);
    map.addMarker(markerOptions);

    Button TWD97_to_WGS84=(Button)findViewById(R.id.latlontest);
    TWD97_to_WGS84.setOnClickListener(new TWD97ModeChange());
}
项目:mocket_android_demo    文件:MapsActivity.java   
@Override
public void onLocationChanged(Location location) {

  //place marker at current position
  //mGoogleMap.clear();
  if (currLocationMarker != null) {
    currLocationMarker.remove();
  }
  latLng = new LatLng(location.getLatitude(), location.getLongitude());
  MarkerOptions markerOptions = new MarkerOptions();
  markerOptions.position(latLng);
  markerOptions.title(getString(R.string.current_position));
  markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
  currLocationMarker = mGoogleMap.addMarker(markerOptions);

  //zoom to current position:
  CameraPosition cameraPosition = new CameraPosition.Builder()
    .target(latLng).zoom(14).build();

  mGoogleMap.animateCamera(CameraUpdateFactory
    .newCameraPosition(cameraPosition));

  mMocketClient.pushLatLngToServer(latLng);
}
项目:Capstoneproject1    文件:LocateActivity.java   
@Override
public void onMapReady(GoogleMap map) {
    MapReady = true;
    LatLng redchillies = new LatLng(37.428162, -121.906481);
    gmap = map;
    gmap.addMarker(new MarkerOptions().position(redchillies).title(getString(R.string.reds)));
    CameraPosition cp = CameraPosition.builder().target(redchillies).zoom(17).bearing(0).tilt(25).build();
    gmap.moveCamera(CameraUpdateFactory.newCameraPosition(cp));
    try {
        //    mapFragment.getMapAsync(this);
        gmap.setMyLocationEnabled(true);
    } catch (SecurityException e) {
        e.printStackTrace();
    }

    gmap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    //  gmap.setTrafficEnabled(true);
    // gmap.setIndoorEnabled(true);
    gmap.setBuildingsEnabled(true);
    gmap.getUiSettings().setZoomControlsEnabled(true);
}