问题
I have set two infowindow for pickup and drop location. I want to change info window postion like uber in the below images,
Below code is what I have tried :
@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();
}
}
How can I achieve this exactly like uber?
来源:https://stackoverflow.com/questions/49687075/change-infowindow-position-according-to-move-right-and-left-side-map