0
持つすべてのマーカーを表示します。コンポーネントストアからGoogle map sdk
コンポーネントを使用しています。私は、単一のマーカーをうまく表示することができます。しかし、私はリストにあるすべてのマーカーを表示したい。私はGMSCoordinateBounds
を使用することが提案解決策を見つけたが、私は私が使用しているSDKでそれを見つけることができませんでした。私はCameraUpdate.FitBounds()
を使用しなければならないことを知っています。は、私がGoogleマップ上のすべての私のマーカーを表示したい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文には決して達しませんでした。 –