Я установил Xamarin.Forms.Googlemaps 2.3.0. Но я вижу пустой элемент управления в Android с текстом «Xamarin.Forms.GoogleMaps», а в iOS - ничего.Куда я иду не так?
В Androidmanifest добавлено: -
<meta-data android:name="com.google.android.geo.API_KEY" android:value="API_KEY"/>
В xaml пространство имен: -
xmlns:gmap="clr-namespace:Xamarin.Forms.GoogleMaps;assembly=Xamarin.Forms.GoogleMaps"
Управление: -
<gmap:Map x:Name="map"
Grid.Row="1"
HasZoomEnabled="True"
HeightRequest="{x:Static local:AppConstants.ActivityLogGfxContainerSize}"
InitialCameraUpdate="-23.68, -46.87, 13, 30, 60"
IsShowingUser="True"
MapLongClicked="map_MapLongClicked"
VerticalOptions="FillAndExpand"
WidthRequest="{x:Static local:AppConstants.PadThird}" />
в xaml.cs: -
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
this.locationViewModel = viewModel as LocationControlViewModel;
Check.IsNotNull(locationViewModel);
map.MyLocationEnabled = true;
map.MoveToRegion(Xamarin.Forms.GoogleMaps.MapSpan.FromCenterAndRadius(new Xamarin.Forms.GoogleMaps.Position(this.locationViewModel.Latitude, this.locationViewModel.Longitude), Xamarin.Forms.GoogleMaps.Distance.FromMiles(1)));
}
private async void map_MapLongClicked(object sender, Xamarin.Forms.GoogleMaps.MapLongClickedEventArgs e)
{
this.locationViewModel.Latitude = e.Point.Latitude;
this.locationViewModel.Longitude = e.Point.Longitude;
Xamarin.Forms.GoogleMaps.Pin pin = new Xamarin.Forms.GoogleMaps.Pin
{
Type = Xamarin.Forms.GoogleMaps.PinType.Place,
Position = new Xamarin.Forms.GoogleMaps.Position(this.locationViewModel.Latitude, this.locationViewModel.Longitude),
Label = "test"
};
map.Pins.Clear();
map.Pins.Add(pin);
map.MoveToRegion(Xamarin.Forms.GoogleMaps.MapSpan.FromCenterAndRadius(new Xamarin.Forms.GoogleMaps.Position(this.locationViewModel.Latitude, this.locationViewModel.Longitude), Xamarin.Forms.GoogleMaps.Distance.FromMiles(1)));
var stream = await map.TakeSnapshot();
}