本文整理汇总了Java中com.google.android.gms.maps.GoogleMap.setMyLocationEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java GoogleMap.setMyLocationEnabled方法的具体用法?Java GoogleMap.setMyLocationEnabled怎么用?Java GoogleMap.setMyLocationEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.maps.GoogleMap
的用法示例。
在下文中一共展示了GoogleMap.setMyLocationEnabled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
*/
@Override
public void onMapReady(GoogleMap map) {
mMap = map;
mMapsManager = new MapsManager(this, map);
mGpxManager = new GpxManager(this);
// Check whether this app could get location
if (checkLocationPermission())
map.setMyLocationEnabled(true);
else
askPermission();
// Set the boundaries of Taiwan
MapUtils.setTaiwanBoundaries(map);
// 設定相機位置
if (lastCameraPosition == null)
map.moveCamera(CameraUpdateFactory.newLatLngZoom(TAIWAN_CENTER, STARTING_ZOOM));
else
map.moveCamera(CameraUpdateFactory.newCameraPosition(lastCameraPosition));
mMapsManager.onCameraMove();
// 開啟上次的GPX檔案
if (!mGpxFileList.isEmpty()) {
for (String filePath : mGpxFileList) {
File file = new File(filePath);
mGpxManager.addGpxFile(file, mMapsManager);
}
mGpxManager.refreshDialog();
}
// TODO blue dot beam to indicate user direction
}
示例2: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
public void onMapReady(GoogleMap googleMap) {
if (m_gMap == null) {
m_gMap = googleMap;
GoogleMap map = getMap();
if (map == null) {
MFBUtil.Alert(this, getString(R.string.txtError), getString(R.string.errNoGoogleMaps));
finish();
return;
}
map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
UiSettings settings = map.getUiSettings();
settings.setCompassEnabled(false);
settings.setRotateGesturesEnabled(false);
settings.setScrollGesturesEnabled(true);
settings.setZoomControlsEnabled(false);
settings.setZoomGesturesEnabled(true);
View mapView = getFragmentManager().findFragmentById(R.id.mfbMap).getView();
if (mapView != null && mapView.getViewTreeObserver() != null && mapView.getViewTreeObserver().isAlive()) {
mapView.getViewTreeObserver().addOnGlobalLayoutListener(this);
}
map.setOnMarkerClickListener(this);
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) {
map.setMyLocationEnabled(true);
}
map.setOnMapLongClickListener(this);
updateMapElements();
}
}
示例3: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的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.
* 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) {
GoogleMap mMap = googleMap;
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)
{
return;
}
mMap.setMyLocationEnabled(true);
map = googleMap;
}
示例4: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(final GoogleMap googleMap) {
googleMap.setMyLocationEnabled(true);
googleMap.getUiSettings().setMyLocationButtonEnabled(true);
googleMap.getUiSettings().setMapToolbarEnabled(false);
LatLng latLng = mPointOfInterest.latLng;
if (latLng != null) {
googleMap.addMarker(new MarkerOptions().position(latLng)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng, 16f));
}
}
示例5: onMapReady
import com.google.android.gms.maps.GoogleMap; //导入方法依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
SummaryActivity.this.googleMap = googleMap;
googleMap.setTrafficEnabled(false);
googleMap.setBuildingsEnabled(false);
googleMap.setOnMyLocationButtonClickListener(this);
UiSettings mapUi = googleMap.getUiSettings();
mapUi.setMapToolbarEnabled(false);
mapUi.setAllGesturesEnabled(true);
mapUi.setTiltGesturesEnabled(false);
mapUi.setMyLocationButtonEnabled(true);
for (MarkerOptions markerOptions : pendingMarkersList)
addMarker(markerOptions);
pendingMarkersList.clear();
followUser = true;
if (ActivityCompat.checkSelfPermission(SummaryActivity.this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)
googleMap.setMyLocationEnabled(true);
Location location = LocationService.getBestLastKnownLocation(SummaryActivity.this);
if (location != null) {
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
googleMap.moveCamera(CameraUpdateFactory.zoomTo(18));
}
}