我已经为拾取和放置位置设置了两个infowindow。我想在下面的图像中更改像uber一样的信息窗口位置,
以下代码是我尝试过的:
@Override
public void onCameraIdle() {
//get marker position
Projection projection = googleMap.getProjection();
LatLng markerLocation = null;
LatLng dropMarkerLocation=null;
try {
if (Marker != null) {
markerLocation = Marker.getPosition();
} else {
markerLocation = new LatLng(0.0f, 0.0f);
}
if (MarkerDrop != null) {
dropMarkerLocation = MarkerDrop.getPosition();
} else {
dropMarkerLocation = new LatLng(0.0f, 0.0f);
}
Point screenPosition = projection.toScreenLocation(markerLocation);
Point screenPositiondrop = projection.toScreenLocation(dropMarkerLocation);
final View mapview = mapFragment.getView();
float maxX = mapview.getMeasuredWidth();
float maxY = mapview.getMeasuredHeight();
//Maximum visible region from x and y axis
float x = 0.0f;
float y = 0.0f;
//help of marker postion change infowindow position
if (Marker != null) {
if (screenPosition.x> 100 && screenPosition.x + 160 > maxX) {
//infowindow leftside move
} else {
//infowindow rightside move
}
}
if (MarkerDrop != null) {
if (screenPositiondrop.x < 100 && screenPositiondrop.x + 80 < maxX) {
//infowindow leftside move
} else {
//infowindow rightside move
}
}
}catch (Exception e){
e.printStackTrace();
}
}
我怎样才能像超人一样实现这一目标?