0
Google지도에 내 모든 마커를 표시하고 싶습니다. 구성 요소 저장소에서 Google map sdk
구성 요소를 사용하고 있습니다. 나는 하나의 마커를 잘 보여줄 수있다. 하지만 목록에있는 모든 마커를 보여주고 싶습니다. GMSCoordinateBounds
을 사용하도록 제안 된 솔루션을 찾았지만 사용중인 SDK로 찾을 수 없습니다. 나는 CameraUpdate.FitBounds()
을 써야한다는 것을 안다.Google지도 SDK로 모든 아이콘 표시 iOS Xamarin
아래 코드를 구현했지만 목록의 마지막 마커 만 표시합니다.
private float CalculateMarkerInclusiveZoomLevel(MapView mapView, List<Marker> markers, int minVisible)
{
try
{
var bounds =
new CoordinateBounds(mapView.Projection.VisibleRegion);
var initialZoomLevel = mapView.Camera.Zoom;
markerInclusiveZoomLevel = initialZoomLevel;
var count = markers.Count(
m => bounds.ContainsCoordinate(m.Position));
while (count < markers.Count && count < minVisible)
{
// Each zoom level doubles the viewable area
var latGrowth =
(bounds.NorthEast.Latitude - bounds.SouthWest.Latitude)/2;
var lngGrowth =
(bounds.NorthEast.Longitude - bounds.SouthWest.Longitude)/2;
markerInclusiveZoomLevel--;
bounds = new CoordinateBounds(
new CLLocationCoordinate2D(
bounds.NorthEast.Latitude + latGrowth,
bounds.NorthEast.Longitude + lngGrowth),
new CLLocationCoordinate2D(
bounds.SouthWest.Latitude - latGrowth,
bounds.SouthWest.Longitude - lngGrowth));
count = markers.Count(m => bounds.ContainsCoordinate(m.Position));
return markerInclusiveZoomLevel;
}
}
catch (Exception ex)
{
}
return markerInclusiveZoomLevel;
}
어떻게하면됩니까? 모든 예제가 유용 할 것입니다.
안녕하세요, 저는 처음에 동일한 작업을 시도했지만 return 문에 도달하지 않았습니다. –