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);
}
}

View File

@ -17,18 +17,18 @@
<TableView Intent="Settings" HasUnevenRows="True">
<TableSection Title="{r:Text About}">
<ui:OptionTextCell Height="36" Title="{r:Text Version}"
<ui:OptionTextCell Height="44" Title="{r:Text Version}"
Detail="{Binding Version}"/>
</TableSection>
<TableSection Title="{r:Text Feature}">
<ui:OptionSelectCell Height="36" Title="{r:Text CategoryManage}"
<ui:OptionSelectCell Height="44" Title="{r:Text CategoryManage}"
Detail="{r:Text Detail}"
Command="{Binding CategoryCommand}"/>
<ui:OptionSwitchCell Height="36" Title="{r:Text SaveLocation}"
<ui:OptionSwitchCell Height="44" Title="{r:Text SaveLocation}"
IsToggled="{Binding SaveLocation, Mode=TwoWay}"/>
</TableSection>
<TableSection Title="{r:Text Preference}">
<ui:OptionEntryCell Height="36" Title="{r:Text PrimaryColor}"
<ui:OptionEntryCell Height="44" Title="{r:Text PrimaryColor}"
Text="{Binding PrimaryColor, Mode=TwoWay}"
Keyboard="Text"/>
<ViewCell Height="120">
@ -42,7 +42,7 @@
</ViewCell>
</TableSection>
<TableSection Title="{r:Text Diagnostic}">
<ui:OptionSelectCell Height="36" Title="{r:Text ShareLogs}"
<ui:OptionSelectCell Height="44" Title="{r:Text ShareLogs}"
Detail="{Binding ManyRecords}"
Command="{Binding ShareLogsCommand}"/>
</TableSection>

View File

@ -14,7 +14,8 @@ namespace Billing.Views
if (bill.Latitude != null && bill.Longitude != null)
{
var position = new Position(bill.Latitude.Value, bill.Longitude.Value);
var (longitude, latitude) = Helper.Wgs84ToGcj02(bill.Longitude.Value, bill.Latitude.Value);
var position = new Position(latitude, longitude);
var mapSpan = new MapSpan(position, 0.01, 0.01);
Content = new Map(mapSpan)
{