wgs84 to gcj02

This commit is contained in:
2022-03-18 14:08:17 +08:00
parent f27b0a2564
commit 7ca377b8c2
7 changed files with 74 additions and 25 deletions

View File

@ -16,13 +16,14 @@ namespace Billing.Views
{
private static readonly BindableProperty CheckBillProperty = Helper.Create<Command, AddBillPage>(nameof(CheckBill), defaultValue: new Command(() => { }, () => false));
private static readonly BindableProperty AmountProperty = Helper.Create<string, AddBillPage>(nameof(Amount));
private static readonly BindableProperty NameProperty = Helper.Create<string, AddBillPage>(nameof(Name));
private static readonly BindableProperty NameProperty = Helper.Create<string, AddBillPage>(nameof(Name), defaultValue: string.Empty);
private static readonly BindableProperty CategoryProperty = Helper.Create<Category, AddBillPage>(nameof(Category));
private static readonly BindableProperty WalletProperty = Helper.Create<Account, AddBillPage>(nameof(Wallet));
private static readonly BindableProperty StoreProperty = Helper.Create<string, AddBillPage>(nameof(Store));
private static readonly BindableProperty CreatedDateProperty = Helper.Create<DateTime, AddBillPage>(nameof(CreatedDate));
private static readonly BindableProperty CreatedTimeProperty = Helper.Create<TimeSpan, AddBillPage>(nameof(CreatedTime));
private static readonly BindableProperty NoteProperty = Helper.Create<string, AddBillPage>(nameof(Note));
private static readonly BindableProperty ViewLocationProperty = Helper.Create<Command, AddBillPage>(nameof(ViewLocation), defaultValue: new Command(() => { }, () => false));
public Command CheckBill => (Command)GetValue(CheckBillProperty);
public string Amount
@ -60,7 +61,7 @@ namespace Billing.Views
public Command SelectCategory { get; }
public Command SelectWallet { get; }
public Command ViewLocation { get; }
public Command ViewLocation => (Command)GetValue(ViewLocationProperty);
public event EventHandler<Bill> BillChecked;
@ -77,7 +78,6 @@ namespace Billing.Views
createDate = date;
SelectCategory = new Command(OnSelectCategory);
SelectWallet = new Command(OnSelectWallet);
ViewLocation = new Command(() => { }, () => false);
InitializeComponent();
Title = Resource.AddBill;
@ -89,10 +89,11 @@ namespace Billing.Views
this.bill = bill;
SelectCategory = new Command(OnSelectCategory);
SelectWallet = new Command(OnSelectWallet);
#if __ANDROID__
ViewLocation = new Command(() => { }, () => false);
#else
ViewLocation = new Command(OnViewLocation, () => bill != null && bill.Latitude != null && bill.Longitude != null);
#if __IOS__
if (bill != null && bill.Latitude != null && bill.Longitude != null)
{
SetValue(ViewLocationProperty, new Command(OnViewLocation));
}
#endif
InitializeComponent();
Title = Resource.EditBill;
@ -160,6 +161,12 @@ namespace Billing.Views
return;
}
location = await Geolocation.GetLocationAsync(request, tokenSource.Token);
#if __IOS__
if (bill == null)
{
SetValue(ViewLocationProperty, new Command(OnViewLocation));
}
#endif
}
catch (FeatureNotSupportedException) { }
catch (FeatureNotEnabledException) { }
@ -170,7 +177,7 @@ namespace Billing.Views
}
finally
{
SetValue(CheckBillProperty, new Command(OnCheckBill));
SetValue(CheckBillProperty, new Command(OnCheckBill));
}
}
@ -292,7 +299,7 @@ namespace Billing.Views
private async void OnViewLocation()
{
if (bill == null)
if (bill == null && location == null)
{
return;
}
@ -302,7 +309,13 @@ namespace Billing.Views
}
using (Tap.Start())
{
var page = new ViewLocationPage(bill);
var page = new ViewLocationPage(bill ?? new Bill
{
Name = Name,
Store = Store,
Longitude = location.Longitude,
Latitude = location.Latitude
});
await Navigation.PushAsync(page);
}
}