2016-03-29 24 views
0

Googleマップの任意のマーカーをクリックすると、地図の右上に情報ウィンドウが表示されます。 情報ウィンドウは常にマップの右上に表示されます。Googleマップの右上にGoogleマップの情報ウィンドウを表示したい

 // Setting a custom info window adapter for the google map 
    mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { 

     // Use default InfoWindow frame if return null 
     // else inflate any layout 
     @Override 
     public View getInfoWindow(Marker marker) { 

      /*showAlertToChooseImage();*/ 
      if (!marker.getTitle().equalsIgnoreCase("Helipad")) { 
       // Getting view from the layout file info_window_layout 
       View view = getActivity().getLayoutInflater().inflate(R.layout.windowlayout, null); 

       // Getting reference to the TextView to set latitude 
       TextView tvGroupName = (TextView) view.findViewById(R.id.txtViewGroupName); 
       tvGroupName.setText(modelItemMarker.getIncidentGropName()); 
       // Getting reference to the TextView to set longitude 
       TextView tvAddress = (TextView) view.findViewById(R.id.txtViewAddress); 
       tvAddress.setText(modelItemMarker.getLOCATION_ADDRESS()); 

       TextView tvDateTime = (TextView) view.findViewById(R.id.txtViewDateTime); 
       tvDateTime.setText(modelItemMarker.getIncidentDateTimeField()); 

       // Returning the view containing InfoWindow contents 
       return view; 
      } else { 
       return null; 
      } 
     } 

     // Defines the contents of the InfoWindow 
     @Override 
     public View getInfoContents(Marker arg0) { 
      return null; 
     } 
    }); 

    // Handle click of the infoWindow. 
    mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() { 
     @Override 
     public void onInfoWindowClick(Marker marker) { 
      Bundle bundle = new Bundle(); 
      bundle.putString(Constants.CallNO, modelItemMarker.getCadIdField()); 
      SideMenuFragment_Left.IsChangePwd = false; 
      SideMenuFragment_Right.IsAgencies = false; 
      Intent intent = new Intent(mContext, IncidentDetailActivity.class); 
      intent.putExtra(Constants.INCIDENT_DETAIL, bundle); 
      startActivity(intent); 

     } 
    }); 

誰でも助けてください。

ありがとうございます。

+0

ここにコードを記入してください。今や実装まで何をしていますか? –

+0

@SagarNayak私はそれが助けると思う。 –

+0

あなたは何が必要ですか? XMLで? –

答えて

0

このようにしてください。上記のコードのよう

public class MarkerDemoActivity extends AppCompatActivity implements 
    OnInfoWindowClickListener, 
    OnMapReadyCallback { 

private GoogleMap mMap; 

@Override 
public void onMapReady(GoogleMap map) { 
    mMap = map; 
    // Add markers to the map and do other map setup. 
    ... 
    // Set a listener for info window events. 
    mMap.setOnInfoWindowClickListener(this); 
} 

@Override 
public void onInfoWindowClick(Marker marker) { 
    Toast.makeText(this, "Info window clicked", 
      Toast.LENGTH_SHORT).show(); 
} 
} 
+0

返信前に慎重に質問を読む –

0

あなたは私はあなたが1つのより多くのレイアウトを取る必要があり、あなたがマップにこのレイアウトを追加する必要が考えてい左上隅を行いたい場合は、marker.Butの情報ウィンドウの最上部を取得しますマーカーをクリックしたときの活動

0

Android用Google Maps APIの現在の機能ではこれを達成できません。代わりにWebFrame経由でGoogle Maps Javascript APIを使用してAndroidアプリに実装してみてください。

あなたはpixelOffset位置オプションそのhere上 詳細情報を使用して位置をカスタマイズするInfoWindowOptionsを使用することができます。

関連する問題