ios map fix

This commit is contained in:
2022-03-18 00:55:42 +08:00
parent 4067bc2768
commit a214110c8c
7 changed files with 48 additions and 59 deletions

View File

@ -134,10 +134,12 @@ namespace Billing.Views
protected override void OnLoaded()
{
editorAmount.SetFocus();
if (bill == null)
{
editorAmount.SetFocus();
}
if (bill == null && App.SaveLocation)
{
{
_ = GetCurrentLocation();
}
else

View File

@ -0,0 +1,35 @@
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 position = new Position(bill.Latitude.Value, bill.Longitude.Value);
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
}
}
};
}
}
}
}

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<ui:BillingPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:ui="clr-namespace:Billing.UI"
xmlns:v="clr-namespace:Billing.Views"
xmlns:maps="clr-namespace:Xamarin.Forms.Maps;assembly=Xamarin.Forms.Maps"
x:Class="Billing.Views.ViewLocationPage"
x:Name="viewLocationPage"
x:DataType="v:ViewLocationPage"
BindingContext="{x:Reference viewLocationPage}">
<ContentPage.Content>
<maps:Map x:Name="map" IsShowingUser="False"
MoveToLastRegionOnLayoutChange="False"/>
</ContentPage.Content>
</ui:BillingPage>

View File

@ -1,31 +0,0 @@
using Billing.Models;
using Billing.UI;
using Xamarin.Forms.Maps;
namespace Billing.Views
{
public partial class ViewLocationPage : BillingPage
{
//private readonly Bill bill;
public ViewLocationPage(Bill bill)
{
//this.bill = bill;
Title = bill.Name;
InitializeComponent();
if (bill.Latitude != null && bill.Longitude != null)
{
var address = $"({bill.Latitude}, {bill.Longitude})";
map.Pins.Add(new Pin
{
Label = string.IsNullOrEmpty(bill.Store) ? address : bill.Store,
Type = PinType.Generic,
Position = new Position(bill.Latitude.Value, bill.Longitude.Value),
Address = address
});
}
}
}
}