我有ListView显示位置的数量,当我点击任何位置时,地图显示所有位置列表的标记,但我想在中心显示所选位置的标记,其他区域在那里。
如何在中心显示所选位置,其他位置原样
答案 0 :(得分:0)
gMap是GoogleMap
gMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(com.google.android.gms.maps.model.Marker marker) {
marker.showInfoWindow();
LatLng currentPoint = new LatLng(26.5886, 72.982);// pass here your selected marker coordinate(Latitude & Longitude) like lat
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(currentPoint, 7);// set here your zoom level
gMap.animateCamera(cameraUpdate);
return true;
}
});
例如。
gMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(com.google.android.gms.maps.model.Marker marker) {
marker.showInfoWindow();
YourModel myMarker = mMarkersHashMap.get(marker);// it is your model
LatLng currentPoint = new LatLng(Double.valueOf(myMarker.getLat()), Double.valueOf(myMarker.getLon()));
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(currentPoint, 7);
gMap.animateCamera(cameraUpdate);
return true;
}
});