Billing/Billing.Shared/Views/ViewLocationPage.cs

36 lines
1.1 KiB
C#

using Billing.Models;
using Billing.UI;
using Xamarin.Forms.Maps;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
namespace Billing.Views
{
public class ViewLocationPage : BillingPage
{
public ViewLocationPage(Bill bill)
{
On<Xamarin.Forms.PlatformConfiguration.iOS>().SetUseSafeArea(false);
Title = bill.Name;
if (bill.Latitude != null && bill.Longitude != null)
{
var (longitude, latitude) = (bill.Longitude.Value, bill.Latitude.Value).Wgs84ToGcj02();
var position = new Position(latitude, longitude);
var mapSpan = new MapSpan(position, 0.01, 0.01);
Content = new Map(mapSpan)
{
Pins =
{
new Pin
{
Label = bill.Name,
Type = PinType.Generic,
Position = position,
Address = bill.Store
}
}
};
}
}
}
}