我希望在将标记拖到某个点时显示标记的信息窗口。我希望地址出现在其中。我的 LogCat 为我提供了正确的地址,以便正常工作,但信息窗口未显示
这是我的代码
private void placeMarker() {
getMap().addMarker(new MarkerOptions()
.position(getMyLocation())
.draggable(true)
.snippet("")
.title(""));
getMap().setOnMarkerDragListener(new OnMarkerDragListener() {
public void onMarkerDragStart(Marker arg0) {
// TODO Auto-generated method stub
}
public void onMarkerDragEnd(Marker marker) {
latLng = marker.getPosition();
marker.setSnippet("Loading address...");
marker.showInfoWindow();
Geocoder geoCoder = new Geocoder(getActivity(), Locale.getDefault());
try {
address = geoCoder.getFromLocation(latLng.latitude, latLng.longitude, 1).get(0);
String addressString = address.getAddressLine(0);
addressString += "\n"+address.getAddressLine(1);
marker.setSnippet(addressString);
marker.showInfoWindow();
Log.d("get address pinpoint", "drag end: " + addressString+ " shown:" + marker.isVisible());
} catch (IOException e) {
e.printStackTrace();
}
}
public void onMarkerDrag(Marker arg0) {
// TODO Auto-generated method stub
}
});
}