简体   繁体   中英

Android App Map center when touchs a marker

When I touch a marker on map fragment (v.2), the map is centralized on the touched marker position. How can I drop this behavior? Is it possible? I'd like to keep the title being presented, but with no centralization.

Thanks a lot,

Julio

From the documentation :

You can use an OnMarkerClickListener to listen for click events on the marker. To set this listener on the map, call GoogleMap.setOnMarkerClickListener(OnMarkerClickListener). When a user clicks on a marker, onMarkerClick(Marker) will be called and the marker will be passed through as an argument. This method returns a boolean that indicates whether you have consumed the event (ie, you want to suppress the default behavior). If it returns false, then the default behavior will occur in addition to your custom behavior. The default behavior for a marker click event is to show its info window (if available) and move the camera such that the marker is centered on the map.

This way, you can override the default behavior (center mark+show infowindow) with your custom behavior (show infowindow). Something like this should work:

On your OnMarkerClickListener :

public boolean onMarkerClick(Marker marker) {
    marker.showInfoWindow();
    return true;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM