Note that there are some explanatory texts on larger screens.

plurals
  1. POc# grabbing google maps api address_components
    primarykey
    data
    text
    <p>I'm having trouble pulling individual address components from google map's api results.</p> <p>Here are the results received from this url:</p> <blockquote> <p><a href="http://maps.googleapis.com/maps/api/geocode/json?address=jobing.com+glendale+arizona&amp;sensor=false" rel="nofollow">http://maps.googleapis.com/maps/api/geocode/json?address=jobing.com+glendale+arizona&amp;sensor=false</a></p> </blockquote> <p>This url is in the "uri" variable. Here's the code I'm using to try and retrieve the address_component by type. Take into consideration that I'm a bit new at c#.</p> <pre><code>String Output = client.DownloadString(uri); Dictionary&lt;String, Object&gt; RinkData = JsonConvert.DeserializeObject&lt;Dictionary&lt;String, Object&gt;&gt;(Output); Dictionary&lt;String, Object&gt; RinkDataResults = (Dictionary&lt;String, Object&gt;) RinkData["results"]; if (RinkDataResults.ContainsKey("formatted_address")) { Route = GetAddressComponentByType(RinkDataResults["address_components"], "route"); } </code></pre> <p>And here is the function I'm using "GetAddressComponentByType"</p> <pre><code>protected String GetAddressComponentByType(Object AddressComponents, String AddressType) { Boolean MatchFound = false; String MatchingLongName = ""; Dictionary&lt;String, Object&gt; AddressComponentsDict = (Dictionary&lt;String, Object&gt;)AddressComponents; foreach (KeyValuePair&lt;String, Object&gt; ac in AddressComponentsDict) { Dictionary&lt;String, Object&gt; acDict = (Dictionary&lt;String, Object&gt;) ac.Value; ArrayList acTypes = (ArrayList) acDict["types"]; foreach (String acType in acTypes) { if (acType == AddressType) { MatchFound = true; break; } } if (MatchFound) { MatchingLongName = (String) acDict["long_name"]; } } return MatchingLongName; } </code></pre> <p>The problem is, it doesn't even get to my component retrieval function. It bombs converting RinkData["results"] to a Dictionary saying it's an invalid conversion.</p> <p>Does anyone see what I'm doing wrong? Or maybe someone has a custom object I can read google maps geocode results into that works? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload