Android GoogleMap.InfoWindowAdapter详细信息(&;多段线
我想获取loc.setText上的list_location.get(I).getLatitude()问题是它循环并获取最后一个纬度,添加按钮问题Disclose不起作用,以及如何在单击按钮后在每个标记上添加多段线 这是我的密码:Android GoogleMap.InfoWindowAdapter详细信息(&;多段线,android,google-maps,google-maps-markers,Android,Google Maps,Google Maps Markers,我想获取loc.setText上的list_location.get(I).getLatitude()问题是它循环并获取最后一个纬度,添加按钮问题Disclose不起作用,以及如何在单击按钮后在每个标记上添加多段线 这是我的密码: b.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
for (i = 0; i < list_location.size(); i++) {
createMarker(i, list_location.get(i).getLatitude(), list_location.get(i).getLongitude(), list_location.get(i).getLocation());
}
}
});
return v;
}
private void createMarker(int index, String latitude, String longitude, String snippet) {
// Adding the taped point to the ArrayList
BitmapDescriptor image = BitmapDescriptorFactory.fromResource(R.drawable.ic_menu_camera);
Double lat = Double.parseDouble(latitude);
Double Longitude = Double.parseDouble(longitude);
/* float color = 0;
if (index == 1)
color = BitmapDescriptorFactory.HUE_AZURE;
else if (index == list_location.size()-1)
color = BitmapDescriptorFactory.HUE_VIOLET;*/
if (index == 1)
image = BitmapDescriptorFactory.fromResource(R.drawable.ic_menu_gallery);
else if (index == list_location.size()-1)
image = BitmapDescriptorFactory.fromResource(R.drawable.ic_menu_slideshow);
else {
image = BitmapDescriptorFactory.fromResource(R.drawable.ic_menu_camera);
}
map.addMarker(new MarkerOptions()
.position(new LatLng(lat, Longitude))
.anchor(0.5f, 0.5f)
.title("title")
.snippet(list_location.get(i).getLatitude())
.icon(image));
map.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker arg0) {
return null;
}
@Override
public View getInfoContents(Marker marker) {
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(LAYOUT_INFLATER_SERVICE);
View myContentView = inflater.inflate(R.layout.marker_popup, null);
TextView loc = ((TextView) myContentView
.findViewById(R.id.textView2));
TextView plate_num = ((TextView) myContentView
.findViewById(R.id.textView4));
loc.setText(marker.getTitle());
plate_num.setText(marker.getSnippet());
/* for (int i = 0; i < list_location.size(); i++) {
Log.d("TAG", "getLatitude:" + list_location.get(i).getLatitude() + " getLongitude:" + list_location.get(i).getLongitude());
if (marker.getSnippet().equals(list_location.get(i).getLocation())) {
Log.d("TAG", "Selected Marker");
}
}*/
Button btnDismiss = (Button) myContentView.findViewById(R.id.button2);
btnDismiss.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
}
});
return myContentView;
}
});
b.setOnClickListener(新视图.OnClickListener(){
@凌驾
公共void onClick(视图v){
对于(i=0;i
在列表中\u位置。获取(i)
你从哪里得到i
。我想它应该是索引
,根据你的代码在createMarker
中。嗨,谢谢你的回答。这会做出任何改变。结果是一样的。你能帮我为我的弹出窗口详细信息编写正确的windowAdapter吗?我想在loc.setText上添加一行。另外,我可以如何添加usi单击按钮后,为循环设置坐标..谢谢