2017-11-11 80 views
0

我無法設置myLocationChange偵聽器。 我的代碼如下,我想在OnMapReady方法setMyLocationChangeListener。android中的setOnMyLocationListener錯誤

@Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
          Bundle savedInstanceState) { 

     mapView.getMapAsync(new OnMapReadyCallback() { 
      @Override 
      public void onMapReady(final GoogleMap mMap) { 
       googleMap = mMap; 
       googleMap.setMyLocationEnabled(true); 
       googleMap.setOnMyLocationChangeListener(this); 

    } 

謝謝您的幫助

回答

1

googleMap.setOnMyLocationChangeListener(this);thisOnMapReadyCallback(內部類)。

如果您的外部類實現LocationListener您需要指定它:googleMap.setOnMyLocationChangeListener(YourClass.this);