/// <summary> /// /// </summary> /// <param name="item"></param> private void AddPlaceFromParseObject(ParseObject item, string type = "nearest") { try { var PhotoItem = new AssistsPhoto(); //PhotoItem.Title = item.Get<string>("title"); PhotoItem.Category = item.Get <int>("category"); PhotoItem.Comment = item.Get <string>("comment"); PhotoItem.Lat = item.Get <double>("lat"); PhotoItem.Lon = item.Get <double>("lon"); PhotoItem.ObjectId = item.ObjectId.ToString(); try { var file = item.Get <ParseFile>("photo"); PhotoItem.Image = file.Url.ToString(); if (type == "nearest") { NearestImages.Add(file.Url.ToString()); } ; } catch { }; if (type == "nearest") { //SearchPlaceItems.Add(PhotoItem); NearestPhotoItems.Add(PhotoItem); } else { PhotoItems.Add(PhotoItem); }; } catch { }; }
private void DrawMapMarker(GeoCoordinate coordinate, AssistsPhoto place, MapLayer mapLayer) { // Create a map marker var item = new MapItemControl(); item.Image = place.Image; item.Tag = place.ObjectId; //new GeoCoordinate(coordinate.Latitude, coordinate.Longitude); // Enable marker to be tapped for location information item.MouseLeftButtonUp += new MouseButtonEventHandler(Marker_Click); // Create a MapOverlay and add marker MapOverlay overlay = new MapOverlay(); overlay.Content = item; //polygon; overlay.GeoCoordinate = new GeoCoordinate(coordinate.Latitude, coordinate.Longitude); overlay.PositionOrigin = new System.Windows.Point(0.5, 1.0); mapLayer.Add(overlay); }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <returns></returns> public async Task <bool> SaveItemToParse(AssistsPhoto item) { this.Loading = true; try { ParseObject place = new ParseObject("Place"); place["title"] = item.Title; place["comment"] = item.Comment; place["userId"] = item.UserId; place["lat"] = item.Lat; place["lon"] = item.Lon; place["latlon"] = new ParseGeoPoint(item.Lat, item.Lon); place["authorImage"] = ViewModelLocator.MainStatic.User.UserImage; place["authorUsername"] = ViewModelLocator.MainStatic.User.Username; MemoryStream ms = new MemoryStream(); Extensions.SaveJpeg(item.ImageSource, ms, item.ImageSource.PixelWidth, item.ImageSource.PixelHeight, 0, 100); ParseFile file = new ParseFile("photo" + UnixTimeNow().ToString() + ".jpg", ms.ToArray()); await file.SaveAsync(); item.Image = file.Url.ToString(); place["photo"] = file; await place.SaveAsync(); ViewModelLocator.MainStatic.PhotoItems.Add(item); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); }; this.Loading = false; return(true); }