我有一个Android和iOS的Xamarin Forms Portable应用程序。我的地图一直很好,仍然在iOS中,但在Android中,我只是得到了整个世界的地图。 这是AndroidManifest:
Mixed Content: The page at 'https://**.herokuapp.com/users' was loaded over HTTPS, but requested an insecure resource 'http://localhost:5000/api/users'. This request has been blocked; the content must be served over HTTPS.
这是Android和iOS展位的页面。
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="25" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<application android:label="MyProject" android:icon="@drawable/appicon">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaS...................................." />
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
myMap.MoveToRegion什么都不做。设置所有引脚都是如此,但没有任何反应,仍然是整个世界的地图。
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Comca.Views;assembly=Comca"
xmlns:controls="clr-namespace:Comca.Controls;assembly=Comca"
xmlns:local="clr-namespace:Comca;assembly=Comca"
xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
x:Class="Comca.Pages.LocationsPage">
<ContentPage.Content>
<StackLayout
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand">
<views:PageHeader></views:PageHeader>
<controls:CustomMap x:Name="myMap" MapType="Street"
WidthRequest="{x:Static local:App.ScreenWidth}"
HeightRequest="{x:Static local:App.ScreenHeight}" />
</StackLayout>
</ContentPage.Content>
</ContentPage>
我注意到在customMapRenderer上if(e.PropertyName.Equals(“VisibleRegion”)&amp;&amp;!isDrawn)永远不等于VisibleRegion。 首先是渲染器,然后是Y,然后是宽度和最后高度。
namespace MyProject.Pages
{
public partial class LocationsPage : ContentPage
{
LocationsViewModel LocationsVM { get; set; }
public List<LocationsResponse> Locations { get; set;}
public LocationsPage()
{
InitializeComponent();
myMap.MoveToRegion(
MapSpan.FromCenterAndRadius(
new Position(26.142051, -81.794683), Distance.FromMiles(4)));
}
protected override void OnBindingContextChanged()
{
base.OnBindingContextChanged();
if (this.BindingContext != null)
{
LocationsVM = this.BindingContext as LocationsViewModel;
if (LocationsVM.Locations != null)
{
Locations = LocationsVM.Locations;
foreach (var location in Locations)
{
var latitude = Convert.ToDouble(location.Latitude);
var longitude = Convert.ToDouble(location.Longitude);
var label = $"{location.Name} - {location.Plaza}";
var address = $"{location.Street} {location.Citystate}";
var pin = new CustomPin
{
Pin = new Pin
{
Type = PinType.Place,
Position = new Position(latitude, longitude),
Label = label,
Address = address
},
Hours = location.Hours,
Phone = location.Phone,
Id="Myname",
Url = "http://www.myname.com"
};
myMap.CustomPins = new List<CustomPin> { pin };
myMap.Pins.Add(pin.Pin);
}
}
}
}
}
}
我接手了这个代码,我是Xamarin的新手 谢谢你的帮助。