修改单个定位点地图缩放比例

This commit is contained in:
zhanglei
2025-07-11 10:16:59 +08:00
parent cf849ecfcf
commit cb29fd5678
2 changed files with 13 additions and 4 deletions
@@ -323,9 +323,9 @@ class EmergencyFragment :
return
}
lifecycleScope.launch {
var newlist= mutableListOf<LocationResourceBean>()
var newlist = mutableListOf<LocationResourceBean>()
for (index in 0 until markerList.size) {
if(markerList[index].latitude>0.0&&markerList[index].longitude>0.0){
if (markerList[index].latitude > 0.0 && markerList[index].longitude > 0.0) {
newlist.add(markerList[index])
val markerOption = MarkerOptions()
markerOption.position(
@@ -348,7 +348,12 @@ class EmergencyFragment :
mAMap?.addMarker(markerOption)
}
}
MapUtils.setMapZoonlo(mAMap, 200, ArrayList(newlist))
if (markerList.size == 1) {
MapUtils.setMapZoonloAndZoom(mAMap, LatLng(markerList.get(0).latitude, markerList.get(0).longitude),11)
} else {
MapUtils.setMapZoonlo(mAMap, 200, ArrayList(newlist))
}
}
}
@@ -36,8 +36,12 @@ public class MapUtils {
public static void setMapZoonlo(AMap map, int padding, LatLngBounds.Builder builder){
LatLngBounds bounds = builder.build();
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, padding));
}
public static void setMapZoonloAndZoom(AMap map, LatLng latLng, int zoom){
map.animateCamera(CameraUpdateFactory.newLatLngZoom(latLng,zoom));
}
public static void setMapZoonlo(AMap map, int padding, ArrayList<LocationResourceBean> list){
LatLngBounds.Builder builder = LatLngBounds.builder();
if (list==null||list.size()==0) {