마커를 많이 만들었습니다. 마커의 각 정보 창이 필요합니다. 고유 한 정보 창이 필요합니다. 그러나 정보 창이 xml로 작성되었지만 작동하지 않습니다. 따라서 하나의 이미지가 나타날 때마다 myMap.setInfoWindowAdapter 토스트에 구글 맵스의 다른 마커에 대해 서로 다른 정보를 추가하는 방법 안드로이드에 대한 API v2
// Setting a custom info window adapter for the google map
myMap.setInfoWindowAdapter(new InfoWindowAdapter() {
// Use default InfoWindow frame
public View getInfoWindow(Marker arg0) {
return null;
}
// Defines the contents of the InfoWindow
public View getInfoContents(Marker marker) {
// Getting view from the layout file info_window_layout
View v = getLayoutInflater().inflate(
R.layout.info_window_layout, null);
// Getting the position from the marker
LatLng latLng = marker.getPosition();
Double latitude=latLng.latitude;
Double langitude=latLng.longitude;
String lat = String.format("%.6f", latitude);
String lng = String.format("%.6f", langitude);
Toast.makeText(getApplicationContext(), lat+"----"+lng,Toast.LENGTH_SHORT).show();
// Getting reference to the TextView to set longitude
TextView tvLng = (TextView) v.findViewById(R.id.tv1);
ImageView icon = (ImageView) v.findViewById(R.id.icons);
if(lat.equals("73.057130") && lng.equals("33.721140"))
{
icon.setImageResource(R.drawable.hbl_icon);
}
else
{
icon.setImageResource(R.drawable.alflah_icon);
}
// Returning the view containing InfoWindow contents
return v;
}
});
은 같은 위도을 보여주고 있지만 정보 창은 조건 항상 다른 condition.everything의 이미지를 보여주는 잘 작동하는 경우에 이미지를 표시되지 표시되지만 이미지가 제대로 표시되지 친절하게 도와주세요. 내 XML은 다음과 같습니다
여기
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageView
android:id="@+id/icons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
<TextView
android:id="@+id/tv1"
android:text="Get Directions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp" />
</LinearLayout>
@ m_kiani - 긴 코드를 게시하지 마십시오 ... 요구 사항에 맞는 코드를 게시해야합니다 ... 편집하여 불필요한 코드를 제거하십시오. 최선을 다해 도와 드리겠습니다. – TheFlash
@Pratik 나는 그것을 편집했다. 제발 도움이 .. –
@ m_kiani - 당신은 올바른 논리를 구현했다고 생각합니다 .. 위도와 로그 위치에 따르면 .. 당신은 아이콘을 설정하고 있습니다. 그래서 작동하지 않습니까? – TheFlash