From 30c76ba285e74c6788df62ace696c8e5ceca207d Mon Sep 17 00:00:00 2001 From: Jacques Woolston Date: Wed, 18 May 2016 14:16:08 +0100 Subject: [PATCH] Added place_id to GoogleAddress --- Google/GoogleAddress.cs | 8 +++++--- Google/GoogleGeocoder.cs | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Google/GoogleAddress.cs b/Google/GoogleAddress.cs index e8fda16..b20be50 100644 --- a/Google/GoogleAddress.cs +++ b/Google/GoogleAddress.cs @@ -10,8 +10,9 @@ public class GoogleAddress : Address readonly GoogleAddressComponent[] components; readonly bool isPartialMatch; readonly GoogleViewport viewport; + readonly string place_id; - public GoogleAddressType Type + public GoogleAddressType Type { get { return type; } } @@ -42,7 +43,7 @@ public GoogleAddressComponent this[GoogleAddressType type] } public GoogleAddress(GoogleAddressType type, string formattedAddress, GoogleAddressComponent[] components, - Location coordinates, GoogleViewport viewport, bool isPartialMatch, GoogleLocationType locationType) + Location coordinates, GoogleViewport viewport, bool isPartialMatch, GoogleLocationType locationType, string place_id) : base(formattedAddress, coordinates, "Google") { if (components == null) @@ -53,6 +54,7 @@ public GoogleAddress(GoogleAddressType type, string formattedAddress, GoogleAddr this.isPartialMatch = isPartialMatch; this.viewport = viewport; this.locationType = locationType; - } + this.place_id = place_id; + } } } \ No newline at end of file diff --git a/Google/GoogleGeocoder.cs b/Google/GoogleGeocoder.cs index 93ead37..8f93fa6 100644 --- a/Google/GoogleGeocoder.cs +++ b/Google/GoogleGeocoder.cs @@ -353,7 +353,8 @@ private IEnumerable ParseAddresses(XPathNodeIterator nodes) XPathNavigator nav = nodes.Current; GoogleAddressType type = EvaluateType((string)nav.Evaluate("string(type)")); - string formattedAddress = (string)nav.Evaluate("string(formatted_address)"); + string place_id = (string)nav.Evaluate("string(place_id)"); + string formattedAddress = (string)nav.Evaluate("string(formatted_address)"); var components = ParseComponents(nav.Select("address_component")).ToArray(); @@ -376,7 +377,7 @@ private IEnumerable ParseAddresses(XPathNodeIterator nodes) bool isPartialMatch; bool.TryParse((string)nav.Evaluate("string(partial_match)"), out isPartialMatch); - yield return new GoogleAddress(type, formattedAddress, components, coordinates, viewport, isPartialMatch, locationType); + yield return new GoogleAddress(type, formattedAddress, components, coordinates, viewport, isPartialMatch, locationType, place_id); } }