2016-07-31 25 views
0

爲什麼地圖和位置無法在設備上加1(棉花糖),但在其他設備(我嘗試在Kitkat和棒棒糖它的工作)?所以不能檢測到我們的位置谷歌地圖不能在設備1加1(棉花糖)

enter image description here

這是我的代碼

private void setMap() { 
     mMapFragment.getMapAsync(this); 

    } 
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     if (requestCode == PLACE_PICKER_REQUEST) { 
      if (resultCode == RESULT_OK) { 
       Place place = PlacePicker.getPlace(getApplicationContext(), data); 
       LatLng latLng = new LatLng(place.getLatLng().latitude, place.getLatLng().longitude); 
       googleMap.animateCamera(CameraUpdateFactory.newLatLng(latLng)); 
       googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng)); 
       googleMap.animateCamera(CameraUpdateFactory.zoomTo(15)); 
      } 
     } 
    } 
@Override 
    public void onMapReady(GoogleMap googleMap) { 
     this.googleMap = googleMap; 

     this.googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN); 

     GoogleMapOptions option = new GoogleMapOptions(); 
     option.compassEnabled(true); 
     this.googleMap.setTrafficEnabled(true); 
     if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { 
      return; 
     } 
     googleMap.setMyLocationEnabled(true); 

     googleMap.setOnMyLocationChangeListener(myLocationChangeListener); 

    } 

    private OnMyLocationChangeListener myLocationChangeListener = new OnMyLocationChangeListener() { 
     @Override 
     public void onMyLocationChange(Location location) { 
      if(awal) { 
       awal=false; 
       googleMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(location.getLatitude(), location.getLongitude()))); 
       googleMap.animateCamera(CameraUpdateFactory.zoomTo(13)); 
      } 
     } 
    }; 

回答

相關問題