Hi,
I'm trying to figure out the best way to use an existing Locator service within an MS Access database for verifying that the address being typed in is actually valid. Within my MS Access database I can retrieve the 'score' from the locator service using some code like this:
Private Sub <SPAN class="token function">Command0_Click</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
Dim httpReq As New <SPAN class="token class-name">MSXML2<SPAN class="punctuation token">.</SPAN>ServerXMLHTTP</SPAN>
httpReq<SPAN class="punctuation token">.</SPAN>Open <SPAN class="string token">"GET"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fmaps.durham.ca%2Farcgis%2Frest%2Fservices%2FLocators%2FDurham_Locator%2FGeocodeServer%2FfindAddressCandidates%3FSingleLine%3D66" target="_blank">https://maps.durham.ca/arcgis/rest/services/Locators/Durham_Locator/GeocodeServer/findAddressCandidates?SingleLine=66</A><SPAN> Church Street, Ajax&outfields=Score&f=json"</SPAN></SPAN>
httpReq<SPAN class="punctuation token">.</SPAN>send
Dim response As String
response <SPAN class="operator token">=</SPAN> httpReq<SPAN class="punctuation token">.</SPAN>responseText
Set fs <SPAN class="operator token">=</SPAN> <SPAN class="token function">CreateObject</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Scripting.FileSystemObject"</SPAN><SPAN class="punctuation token">)</SPAN>
Set thefile <SPAN class="operator token">=</SPAN> fs<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CreateTextFile</SPAN><SPAN class="punctuation token">(</SPAN>Application<SPAN class="punctuation token">.</SPAN>CurrentProject<SPAN class="punctuation token">.</SPAN>Path <SPAN class="operator token">&</SPAN> <SPAN class="string token">"\geo.txt"</SPAN><SPAN class="punctuation token">,</SPAN> True<SPAN class="punctuation token">)</SPAN>
thefile<SPAN class="punctuation token">.</SPAN>write <SPAN class="punctuation token">(</SPAN>response<SPAN class="punctuation token">)</SPAN>
thefile<SPAN class="punctuation token">.</SPAN>Close
'MsgBox response
'MsgBox Application<SPAN class="punctuation token">.</SPAN>CurrentProject<SPAN class="punctuation token">.</SPAN>Path
End Sub<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Has anyone done this before? I'm not totally sure of the best approach from here. I guess I could scan the response to look for the score of all the matches, and let the user choose the best one??
I guess I'm just looking for some ideas. The formatting of the JSON that comes back is a bit foreign to me and I'm not
sure of the best way to deal with it.
Here is a sample of what I am getting back from the service:
<SPAN class="punctuation token">{</SPAN><SPAN class="string token">"spatialReference"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"wkid"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">26917</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"latestWkid"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">26917</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"candidates"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"address"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="string token">"66 Church Street North, Ajax"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"location"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"x"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">656188.74132460123</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"y"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">4857786.8273707693</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"score"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">90.870000000000005</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"attributes"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"Score"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">90.870000000000005</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"address"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="string token">"66 Church Street South, Ajax"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"location"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"x"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">656363.87805667717</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"y"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">4857321.912464018</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"score"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">90.870000000000005</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"attributes"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"Score"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">90.870000000000005</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"address"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="string token">"66 Church St S, Ajax"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"location"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"x"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">656335.19874352403</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"y"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">4857300.3138142293</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"score"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">90.870000000000005</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"attributes"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"Score"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">90.870000000000005</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"address"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="string token">"66 Church St S, Ajax"</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"location"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"x"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">656337.24088169797</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"y"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">4857318.2643990703</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"score"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">90.870000000000005</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">"attributes"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">"Score"</SPAN><SPAN class="operator token">:</SPAN><SPAN class="number token">90.870000000000005</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>Or is there a totally different, better way that what I am thinking??
Thanks for any input!!