當前位置: 首頁>>代碼示例>>Java>>正文


Java GoogleMap.setMyLocationEnabled方法代碼示例

本文整理匯總了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
}
 
開發者ID:typebrook,項目名稱:FiveMinsMore,代碼行數:38,代碼來源:MapsActivity.java

示例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();
    }
}
 
開發者ID:ericberman,項目名稱:MyFlightbookAndroid,代碼行數:34,代碼來源:ActFlightMap.java

示例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;
}
 
開發者ID:carlosfaria94,項目名稱:UbiBike-client,代碼行數:20,代碼來源:MapsActivity.java

示例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));
    }
}
 
開發者ID:sathishmscict,項目名稱:Pickr,代碼行數:13,代碼來源:DetailActivity.java

示例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));
    }
}
 
開發者ID:gvinciguerra,項目名稱:custode,代碼行數:29,代碼來源:SummaryActivity.java


注:本文中的com.google.android.gms.maps.GoogleMap.setMyLocationEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。