谷歌地图相机放大,但地图没有

时间:2017-04-28 10:01:12

标签: android google-maps

我有一个奇怪的问题,我还没弄清楚。我在SOF做了大量的研究,但没有一个问题对我有帮助。

我的地图加载没有任何问题,标记定位正确,相机也正确放大到标记但我的问题在于地图本身,它只是不在相机旁边放大。只有在缩小后才能看出地图是否存在(世界地图),但是一旦相机缩放到当前位置,只会看到空白背景,因为地图没有变焦。

这是我编码的方式:

onCreate中的GoogleMap初始化:

api = GoogleApiAvailability.getInstance();
googleservice_status = api.isGooglePlayServicesAvailable(this);
NiceSupportMapFragment fm = (NiceSupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
fm.getMapAsync(this);

OnMapReady方法:

@Override
public void onMapReady(GoogleMap map) {
    googleMap = map;
    initialiseMap();
}

initialiseMap方法:

private void initialiseMap() {
    if (googleMap != null){
        googleMap.getUiSettings().setMyLocationButtonEnabled(true);
    }

    locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
    try {
        locationManager.addGpsStatusListener(this);
    } catch (SecurityException e) {
        nearbranch_value_tv.setText(getString(R.string.branch_without_permissions));
        e.printStackTrace();

    }
    if (googleservice_status != ConnectionResult.SUCCESS) {
        api.showErrorDialogFragment(this,
                googleservice_status,
                PLAY_SERVICES_RESOLUTION_REQUEST);
        searchBar_rl.setVisibility(View.GONE);
        bottom_ll.setClickable(false);
        mainmap_rl.setPadding(0, 70, 0, 45);
    } else {
        readCurrentLocation();
    }
}

readCurrentLocation方法:

private void readCurrentLocation() {
    if (googleMap != null){
        try{
            googleMap.setMyLocationEnabled(true);
        } catch (SecurityException e){
            nearbranch_value_tv.setText(getString(R.string.branch_without_permissions));
            e.printStackTrace();
        }
    }


    boolean isGPSEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);

    if (locationManager == null || !isGPSEnabled) {
        isLocationError = true;
        if (application.NEAR_BRANCH_ADDRESS == null || application.NEAR_BRANCH_ADDRESS.equals(""))
            setDefaultBLMsg(getResources().getString(R.string.locn_srvc_turn_on_msg));
    }


    boolean isNetworkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

    if (isNetworkEnabled && (locationManager != null)) {
        try {
            currentLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
        } catch (SecurityException e) {
            nearbranch_value_tv.setText(getString(R.string.branch_without_permissions));
            e.printStackTrace();

        }


        if (isGPSEnabled && (locationManager != null)) {

            try {
                final Location locationGps = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
                if (locationGps != null) {
                    currentLocation = locationGps;
                }
            } catch (SecurityException e) {
                nearbranch_value_tv.setText(getString(R.string.branch_without_permissions));
                e.printStackTrace();
            }


        }
    }
}

一旦我从服务器得到回复,这就是我将相机设置到位置的方式:

googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
                            point, 15));

有人能说出为什么地图本身没有使用相机进行缩放吗?

感谢任何帮助

0 个答案:

没有答案
相关问题