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


Java CameraPosition类代码示例

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


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

示例1: onMapReady

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

import com.google.android.gms.maps.model.CameraPosition; //导入依赖的package包/类
private static SupportMapFragment newMapFragment() {
    return SupportMapFragment.newInstance(new GoogleMapOptions()
            .camera(new CameraPosition.Builder()
                    .target(LocationAdapter.ZERO)
                    .zoom(DEFAULT_ZOOM)
                    .build()));
}
 
开发者ID:ArnauBlanch,项目名称:civify-app,代码行数:8,代码来源:CivifyMap.java

示例3: onMapReady

import com.google.android.gms.maps.model.CameraPosition; //导入依赖的package包/类
@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));
}
 
开发者ID:gnujavasergio,项目名称:android-googlemaps,代码行数:23,代码来源:MapFragment.java

示例4: onLocationChanged

import com.google.android.gms.maps.model.CameraPosition; //导入依赖的package包/类
@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());

    }

}
 
开发者ID:fekracomputers,项目名称:MuslimMateAndroid,代码行数:24,代码来源:MosquesActivity.java

示例5: doInBackground

import com.google.android.gms.maps.model.CameraPosition; //导入依赖的package包/类
@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;
}
 
开发者ID:medialab-prado,项目名称:puremadrid,代码行数:26,代码来源:MyMapFragment.java

示例6: onStop

import com.google.android.gms.maps.model.CameraPosition; //导入依赖的package包/类
@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.
}
 
开发者ID:typebrook,项目名称:FiveMinsMore,代码行数:25,代码来源:MapsActivity.java

示例7: moveToPosition

import com.google.android.gms.maps.model.CameraPosition; //导入依赖的package包/类
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));

}
 
开发者ID:LewisVo,项目名称:Overkill,代码行数:19,代码来源:MapsActivity2.java

示例8: onMapReady

import com.google.android.gms.maps.model.CameraPosition; //导入依赖的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.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));
}
 
开发者ID:LewisVo,项目名称:Overkill,代码行数:26,代码来源:MapsActivity.java

示例9: moveMapCamera

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

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

示例11: updateCamera

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

示例12: startLocation

import com.google.android.gms.maps.model.CameraPosition; //导入依赖的package包/类
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));
        }
    }
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:22,代码来源:VoteFragment.java

示例13: onCameraChange

import com.google.android.gms.maps.model.CameraPosition; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:19,代码来源:GridClusteringStrategy.java

示例14: onLocationChanged

import com.google.android.gms.maps.model.CameraPosition; //导入依赖的package包/类
@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);
}
 
开发者ID:Nishant-Pathak,项目名称:mocket_android_demo,代码行数:25,代码来源:MapsActivity.java

示例15: setUpMap

import com.google.android.gms.maps.model.CameraPosition; //导入依赖的package包/类
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);
        }
    });
}
 
开发者ID:mkeresztes,项目名称:AndiCar,代码行数:22,代码来源:GPSTrackMap.java


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