2016-09-27 14 views
2

Google APIを使用しています。マーカー用のカスタム情報ウィンドウを作成しました。 ツールバーのマップを表示する必要がありますが、このメソッドを使用してください。 map.getUiSettings()。 setMapToolbarEnabled(true)、 マーカーをクリックすると、インフォウィンドウが表示されますが、ツールバーは表示されません。android map.getUiSettings()。setMapToolbarEnabled(true)、なぜツールバーが表示されませんか?

enter image description here

CODE:

@Override ます。public void onMapReady(GoogleマップGoogleマップ){

mMap = googleMap; 
    mMap.getUiSettings().setMapToolbarEnabled(true); 
    mMap.setOnMarkerClickListener(this); 
    mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() { 
     @Override 
     public void onInfoWindowClick(Marker marker) { 


      MarkerCouple idtype = (MarkerCouple) marker.getTag(); 

      if (idtype.getType() == ResourceType.EVENTS && currentEvents.get(idtype.getID()) != null) { 

       Resources resources = currentResources.get(currentEvents.get(idtype.getID()).getRes_ID()); 
       Events event = currentEvents.get(idtype.getID()); 

       Intent i = new Intent(MainActivity.this, ShowEventActivity.class); 
       i.putExtra(Variable.USER_JSON, user.toJSON()); 
       i.putExtra(Variable.EVENT_JSON, event.toJSON()); 
       i.putExtra(Variable.RESOURCE_JSON, resources.toJSON()); 

       startActivityForResult(i, Variable.SHOW_EVENT); 
      } 

      if (idtype.getType() == ResourceType.PLACES && currentPlaces.get(idtype.getID()) != null) { 
       Resources resources = currentResources.get(currentPlaces.get(idtype.getID()).getRes_ID()); 
       Places place = currentPlaces.get(idtype.getID()); 

       Intent i = new Intent(MainActivity.this, ShowPlaceActivity.class); 
       i.putExtra(Variable.USER_JSON, user.toJSON()); 
       i.putExtra(Variable.PLACE_JSON, place.toJSON()); 
       i.putExtra(Variable.RESOURCE_JSON, resources.toJSON()); 

       startActivityForResult(i, Variable.SHOW_PLACE); 

      } 
     } 
    }); 

    mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { 
     @Override 
     public View getInfoWindow(Marker marker) { 

      View v = getLayoutInflater().inflate(R.layout.marker_preview, null); 
      ImageView m = (ImageView) v.findViewById(R.id.marker_image); 
      m.setImageBitmap(Bitmap.createScaledBitmap(imageToShow, 600, 400, true)); 
      return v; 
     } 

     @Override 
     public View getInfoContents(Marker marker) { 


      return null; 
     } 
    }); 
    new MarkerAsync().execute(); 


} 

@Override 
public boolean onMarkerClick(final Marker marker) { 

    MarkerCouple idtype = (MarkerCouple) marker.getTag(); 


    if (idtype.getType() == ResourceType.EVENTS && currentEvents.get(idtype.getID()) != null) { 
     Events event = currentEvents.get(idtype.getID()); 
     final Resources resources = currentResources.get(event.getRes_ID()); 
     Picasso.with(MainActivity.this).invalidate(Variable.DOWNLOAD_URL + resources.getURI()); 
     new AsyncTask<Void, Void, Void>() { 
      @Override 
      protected Void doInBackground(Void... params) { 
       try { 
        imageToShow = Picasso.with(MainActivity.this).load(Variable.DOWNLOAD_URL + resources.getURI()).get(); 
       } catch (IOException e) { 
        e.printStackTrace(); 
       } 
       return null; 
      } 

      @Override 
      protected void onPostExecute(Void v) { 
       marker.showInfoWindow(); 

      } 
     }.execute(); 


    } 


    if (idtype.getType() == ResourceType.PLACES && currentPlaces.get(idtype.getID()) != null) { 

     Places place = currentPlaces.get(idtype.getID()); 
     final Resources resources = currentResources.get(place.getRes_ID()); 
     Picasso.with(MainActivity.this).invalidate(Variable.DOWNLOAD_URL + resources.getURI()); 
     Picasso.with(MainActivity.this).invalidate(Variable.DOWNLOAD_URL + resources.getURI()); 
     new AsyncTask<Void, Void, Void>() { 
      @Override 
      protected Void doInBackground(Void... params) { 
       try { 
        imageToShow = Picasso.with(MainActivity.this).load(Variable.DOWNLOAD_URL + resources.getURI()).get(); 
       } catch (IOException e) { 
        e.printStackTrace(); 
       } 
       return null; 
      } 

      @Override 
      protected void onPostExecute(Void v) { 
       marker.showInfoWindow(); 

      } 
     }.execute(); 

    } 


    return true; 
} 
+0

あなたのコード –

+0

を投稿してください私はfalseを返す場合、私は例外ではどのような例外をスロー – helloimluca

答えて

1

だけreturn false;the documentationからあなたonMarkerClick()

から:

パブリック抽象ブールonMarkerClick(マーカーマーカー)

戻り

真のリスナーが(すなわち、そうでない場合はfalse、(つまり、デフォルトの動作は発生しません)イベントを消費している場合デフォルトの動作が発生するはずです)。デフォルトの動作では、カメラがマーカーに移動し、情報ウィンドウが表示されます。

+0

を掲載しましたか? – helloimluca

+0

私のコード – antonio

+0

java.lang.NullPointerException:ヌルオブジェクトリファレンスで仮想メソッド 'int android.graphics.Bitmap.getWidth()'を呼び出そうとしました。 android.graphics.Bitmap.createScaledBitmap(Bitmap.java:591) at tesi.myview .MainActivity $ 3.getInfoWindow(MainActivity.java:274) – helloimluca

関連する問題