private void AddPushpin(Waypoint poi, int ID) { Pushpin pp = null; if (poi is PointOfInterest) { PointOfInterest poii = poi as PointOfInterest; pp = new Pushpin() { Tag = new InfoBoxData() { Title = poii.Name, Description = poii.Information, ImagePath = poii.ImagePath } }; pp.Background = new SolidColorBrush(Windows.UI.Colors.Red); } else { pp = new Pushpin(); pp.Background = new SolidColorBrush(Windows.UI.Colors.Blue); } MapLayer.SetPosition(pp, new Location(poi.Latitude, poi.Longitude)); pp.Tapped += PinTapped; layer.Children.Add(pp); Geocircle circle = new Geocircle(new BasicGeoposition() { Latitude = poi.Latitude, Longitude = poi.Longitude, Altitude=0 }, 15); Geofence fence = new Geofence(""+ID, circle, MonitoredGeofenceStates.Entered, false, new TimeSpan(10)); GeofenceMonitor.Current.Geofences.Add(fence); }
public static DatabasePOI ToDatabasePOIIDless(Waypoint toConvert, int id) { return new DatabasePOI(toConvert.Latitude, toConvert.Longitude, id); }
public static DatabasePOI ToDatabasePOI(Waypoint toConvert) { return new DatabasePOI(toConvert.Latitude, toConvert.Longitude, DatabaseConnector.INSTANCE.generateWaypointID()); }
public async Task EditWaypointAsync(Waypoint oldWaypoint, Waypoint newWaypoint) { //Remember the ID int id = Database.QueryAsync<DatabasePOI>("SELECT WaypointID FROM \"DatabasePOI\" WHERE \"Latitude\" = ? AND \"Longitude\" = ?", new object[] { oldWaypoint.Latitude, oldWaypoint.Longitude }).Result[0].WaypointID; await DeleteWaypoint(oldWaypoint); //If the exact coordinates are still in use, disregard. This shouldn't happen, but you'll never be certain List<DatabasePOI> exists = await Database.QueryAsync<DatabasePOI>("SELECT \"Latitude\", \"Longitude\" FROM \"DatabasePOI\" WHERE \"Latitude\" = ? AND \"Longitude\" = ?", new object[] { newWaypoint.Latitude, newWaypoint.Longitude }); if (exists.Count != 0) return; DatabasePOI forDatabase; //Otherwises insert as Point Of Interest (Contains a name) if (newWaypoint is PointOfInterest) { forDatabase = DatabasePOI.ToDatabasePOIIDless(newWaypoint as PointOfInterest, id); } //Or waypoint (Without metadata) else { forDatabase = DatabasePOI.ToDatabasePOIIDless(newWaypoint, id); } await Database.InsertAsync(forDatabase); }
public async Task<int> SaveWaypoint(Waypoint waypoint) { //If the exact coordinates are already used, disregard. List<DatabasePOI> exists = await Database.QueryAsync<DatabasePOI>("SELECT \"Latitude\", \"Longitude\" FROM \"DatabasePOI\" WHERE \"Latitude\" = ? AND \"Longitude\" = ?", new object[] { waypoint.Latitude, waypoint.Longitude}); if(exists.Count != 0) return exists[0].WaypointID; DatabasePOI forDatabase; //Otherwises insert as Point Of Interest (Contains at least a name) if(waypoint is PointOfInterest){ forDatabase = DatabasePOI.ToDatabasePOI(waypoint as PointOfInterest); } //Or waypoint (Without metadata) else { forDatabase = DatabasePOI.ToDatabasePOI(waypoint); } await Database.InsertAsync(forDatabase); return forDatabase.WaypointID; }
public async Task DeleteWaypoint(Waypoint waypoint) { await DeleteWaypoint(waypoint.Latitude, waypoint.Longitude); }