public LocationFinderItem (CustomerProfile person, LocationInfo address) { this.Type = LocationFinderItemType.Contact; this.DataItem = address; //this.Text = string.Format ("{0} {1}", person.FirstName, person.LastName); this.Detail = address.StreetAddress; this.FormattedAddress = address.FormattedAddress; this.Lat = address.Lat; this.Lng = address.Lng; }
public LocationFinderItem (LocationInfo address) { this.Type = LocationFinderItemType.Address; if (address.ProviderType == LocationLookupProviderType.GooglePlace) this.Type = LocationFinderItemType.Place; else if (address.ProviderType == LocationLookupProviderType.Google && !string.IsNullOrWhiteSpace (address.Name)) this.Type = LocationFinderItemType.Establishment; // treat a google establishment as a place if (address.ProviderType == LocationLookupProviderType.Bing) { address.StreetAddress = address.StreetAddress; } if (!string.IsNullOrEmpty (address.Landmark)) address.StreetAddress = address.StreetAddress; this.DataItem = address; if (this.Type == LocationFinderItemType.Address || this.Type == LocationFinderItemType.Establishment) { if (!string.IsNullOrWhiteSpace (address.Name)) { this.Text = address.Name; this.Detail = string.Format ("{0}\n{1}, {2} {3}", address.StreetAddress, address.City, address.State, address.Zip); } else { this.Text = address.StreetAddress; this.Detail = string.Format ("{0}, {1} {2}", address.City, address.State, address.Zip); } this.FormattedAddress = address.FormattedAddress; this.Lat = address.Lat; this.Lng = address.Lng; } else { if (address.PlaceInfo != null) { var parts = address.PlaceInfo.Split (','); if (parts.Length == 0) { this.Text = address.PlaceInfo; } else { int firstHalf = (int)Math.Floor ((double)parts.Length / 2.0); this.Text = string.Join (", ", parts.Take (firstHalf).ToArray ()); this.Detail = string.Join (", ", parts.Skip (firstHalf).ToArray ()); } // prepend the name of the place if present, and it isn't already in the Text if (!string.IsNullOrWhiteSpace (address.Name) && this.Text.IndexOf (address.Name) == -1) this.Text = string.Format ("{0}\n{1}", address.Name, this.Text.Replace (address.Name, "")); } } }