geolocation
This commit is contained in:
parent
43d3231ccf
commit
9940b5a4ca
8 changed files with 81 additions and 40 deletions
|
|
@ -48,6 +48,7 @@ namespace ZicMoove.Droid
|
|||
using Model.Auth.Account;
|
||||
using static Android.Manifest;
|
||||
using Settings;
|
||||
using Model.Auth;
|
||||
|
||||
[Activity(Name = "fr.pschneider.bas.MainActivity", Label = "ZicMoove", Theme = "@style/MainTheme", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
|
||||
public class MainActivity :
|
||||
|
|
@ -398,28 +399,12 @@ namespace ZicMoove.Droid
|
|||
// TODO handle
|
||||
}
|
||||
|
||||
public class GCMDeclaration : IGCMDeclaration
|
||||
{
|
||||
public string DeviceId
|
||||
{ get; set; }
|
||||
|
||||
public string GCMRegistrationId
|
||||
{ get; set; }
|
||||
|
||||
public string Model
|
||||
{ get; set; }
|
||||
|
||||
public string Platform
|
||||
{ get; set; }
|
||||
|
||||
public string Version
|
||||
{ get; set; }
|
||||
}
|
||||
|
||||
public IGCMDeclaration GetDeviceInfo()
|
||||
{
|
||||
var devinfo = CrossDeviceInfo.Current;
|
||||
return new GCMDeclaration
|
||||
return new GCMRegIdDeclaration
|
||||
{
|
||||
DeviceId = devinfo.Id,
|
||||
GCMRegistrationId = MainSettings.GoogleRegId,
|
||||
|
|
|
|||
|
|
@ -197,6 +197,7 @@ namespace ZicMoove
|
|||
{ get { return userProfilePage; } }
|
||||
|
||||
ChatPage chatPage;
|
||||
PinPage pinPage;
|
||||
|
||||
public static void ShowPage(Page page)
|
||||
{
|
||||
|
|
@ -248,6 +249,9 @@ namespace ZicMoove
|
|||
Icon = "",
|
||||
BindingContext = new ChatViewModel()
|
||||
};
|
||||
|
||||
pinPage = new PinPage();
|
||||
|
||||
// var mainPage = new NavigationPage(bQueriesPage);
|
||||
|
||||
masterDetail = new ExtendedMasterDetailPage()
|
||||
|
|
@ -293,6 +297,14 @@ namespace ZicMoove
|
|||
() => { ShowPage(chatPage); }
|
||||
)
|
||||
};
|
||||
ToolbarItem tiPinPage = new ToolbarItem()
|
||||
{
|
||||
Text = "Map",
|
||||
Icon = "glyphish_103_map.png",
|
||||
Command = new Command(
|
||||
() => { ShowPage(pinPage); }
|
||||
)
|
||||
};
|
||||
masterDetail.ToolbarItems.Add(tiHome);
|
||||
masterDetail.ToolbarItems.Add(tiSetts);
|
||||
masterDetail.ToolbarItems.Add(tiPubChat);
|
||||
|
|
|
|||
27
ZicMoove/ZicMoove/Model/Auth/GCRegIdDeclaration.cs
Normal file
27
ZicMoove/ZicMoove/Model/Auth/GCRegIdDeclaration.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yavsc.Models.Identity;
|
||||
|
||||
namespace ZicMoove.Model.Auth
|
||||
{
|
||||
public class GCMRegIdDeclaration : IGCMDeclaration
|
||||
{
|
||||
public string DeviceId
|
||||
{ get; set; }
|
||||
|
||||
public string GCMRegistrationId
|
||||
{ get; set; }
|
||||
|
||||
public string Model
|
||||
{ get; set; }
|
||||
|
||||
public string Platform
|
||||
{ get; set; }
|
||||
|
||||
public string Version
|
||||
{ get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -12,10 +12,19 @@ namespace ZicMoove.Model.Social
|
|||
/// </summary>
|
||||
public class Position
|
||||
{
|
||||
public Position()
|
||||
{
|
||||
}
|
||||
|
||||
public Position(double lat, double lon)
|
||||
{
|
||||
Latitude = lat;
|
||||
Longitude = lon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The longitude.
|
||||
/// </summary>
|
||||
|
||||
public double Longitude { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -3,23 +3,27 @@ using System;
|
|||
using Xamarin.Forms;
|
||||
using Xamarin.Forms.Maps;
|
||||
using Yavsc;
|
||||
using ZicMoove.Data;
|
||||
using System.Threading.Tasks;
|
||||
using XLabs.Platform.Services.Geolocation;
|
||||
using Plugin.Geolocator;
|
||||
|
||||
namespace ZicMoove.Pages
|
||||
{
|
||||
public class PinPage : ContentPage
|
||||
{
|
||||
Map map;
|
||||
/*
|
||||
protected async Task<Geolocator.Plugin.Abstractions.Position> GetPos() {
|
||||
|
||||
protected async Task<Plugin.Geolocator.Abstractions.Position> GetPos() {
|
||||
var locator = CrossGeolocator.Current;
|
||||
locator.DesiredAccuracy = 50;
|
||||
|
||||
return await locator.GetPositionAsync (timeout: 10000);
|
||||
return await locator.GetPositionAsync (10000);
|
||||
}
|
||||
|
||||
|
||||
private Position _pos;
|
||||
public Position MyPosition {
|
||||
private Model.Social.Position _pos;
|
||||
public Model.Social.Position MyPosition {
|
||||
get {
|
||||
return _pos;
|
||||
}
|
||||
|
|
@ -28,9 +32,9 @@ namespace ZicMoove.Pages
|
|||
public async Task UpdateMyPos()
|
||||
{
|
||||
var pos = await GetPos();
|
||||
_pos = new Position(pos.Latitude,pos.Longitude);
|
||||
_pos = new Model.Social.Position(pos.Latitude,pos.Longitude);
|
||||
}
|
||||
*/
|
||||
|
||||
protected override void OnAppearing ()
|
||||
{
|
||||
base.OnAppearing ();
|
||||
|
|
@ -49,19 +53,20 @@ namespace ZicMoove.Pages
|
|||
double lat=0;
|
||||
double lon=0;
|
||||
int pc = 0;
|
||||
foreach (LocalizedEvent ev in Manager.Events) {
|
||||
var pin = new Pin {
|
||||
foreach (var query in DataManager.Instance.BookQueries)
|
||||
{
|
||||
var pin = new Pin {
|
||||
Type = PinType.SearchResult,
|
||||
Position = new Xamarin.Forms.Maps.Position(
|
||||
ev.Location.Latitude, ev.Location.Longitude),
|
||||
Label = ev.Title,
|
||||
Address = ev.Location.Address
|
||||
query.Location.Latitude, query.Location.Longitude),
|
||||
Label = query.Reason,
|
||||
Address = query.Location.Address
|
||||
};
|
||||
pin.BindingContext = ev;
|
||||
pin.BindingContext = query;
|
||||
map.Pins.Add (pin);
|
||||
// TODO find a true solution
|
||||
lat = (lat * pc + ev.Location.Latitude) / (pc + 1);
|
||||
lon = (lon * pc + ev.Location.Longitude) / (pc + 1);
|
||||
lat = (lat * pc + query.Location.Latitude) / (pc + 1);
|
||||
lon = (lon * pc + query.Location.Longitude) / (pc + 1);
|
||||
pc++;
|
||||
}
|
||||
// TODO build a MapSpan covering events
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
<ListView x:Name="AccountListView"
|
||||
SeparatorVisibility="Default"
|
||||
VerticalOptions="FillAndExpand"
|
||||
ItemsSource="{x:Static local:MainSettings.AccountList}"
|
||||
ItemsSource="{x:Static local:Settings.MainSettings.AccountList}"
|
||||
>
|
||||
<ListView.Header>
|
||||
<StackLayout Orientation="Horizontal">
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ using Xamarin.Forms;
|
|||
using XLabs.Forms.Behaviors;
|
||||
using XLabs.Forms.Controls;
|
||||
using XLabs.Forms.Mvvm;
|
||||
using XLabs.Ioc;
|
||||
using XLabs.Platform.Services;
|
||||
|
||||
namespace ZicMoove.ViewModels.UserProfile
|
||||
{
|
||||
|
|
@ -138,8 +136,6 @@ namespace ZicMoove.ViewModels.UserProfile
|
|||
}
|
||||
}
|
||||
|
||||
private bool userIsPro = false;
|
||||
|
||||
public UserProfileViewModel()
|
||||
{
|
||||
Accounts = MainSettings.AccountList;
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@
|
|||
<Compile Include="Data\EstimateEntity.cs" />
|
||||
<Compile Include="Data\NonCrUD\RemoteFiles.cs" />
|
||||
<Compile Include="Model\Access\BlackListed.cs" />
|
||||
<Compile Include="Model\Auth\GCRegIdDeclaration.cs" />
|
||||
<Compile Include="Model\Booking\MusicalPreference.cs" />
|
||||
<Compile Include="Model\Booking\MusicalTendency.cs" />
|
||||
<Compile Include="Model\FileSystem\UserDirectoryInfo.cs" />
|
||||
|
|
@ -219,7 +220,7 @@
|
|||
<Compile Include="Pages\HomePage.xaml.cs">
|
||||
<DependentUpon>HomePage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\Oooops\PinPage.cs" />
|
||||
<Compile Include="Pages\EstimatePages\PinPage.cs" />
|
||||
<Compile Include="ViewModels\EstimateAndBilling\BookQueriesViewModel.cs" />
|
||||
<Compile Include="ViewModels\EstimateAndBilling\BookQueryViewModel.cs" />
|
||||
<Compile Include="ViewModels\EstimateAndBilling\BillingLineViewModel.cs" />
|
||||
|
|
@ -299,6 +300,12 @@
|
|||
<Reference Include="Plugin.Connectivity.Abstractions">
|
||||
<HintPath>..\..\packages\Xam.Plugin.Connectivity.2.2.12\lib\MonoAndroid10\Plugin.Connectivity.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Plugin.Geolocator">
|
||||
<HintPath>..\..\packages\Xam.Plugin.Geolocator.3.0.4\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Plugin.Geolocator.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Plugin.Geolocator.Abstractions">
|
||||
<HintPath>..\..\packages\Xam.Plugin.Geolocator.3.0.4\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10\Plugin.Geolocator.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Plugin.Media">
|
||||
<HintPath>..\..\packages\Xam.Plugin.Media.2.3.0\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Plugin.Media.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue