geocoding from address to Latitude and Longitude

UHsoccer

Well-known Member
Joined
Apr 3, 2002
Messages
1,023
I have been running a spreadsheet that knows how to convert an address to Latitude and Longitude values.
It uses a yahoo MapsService.
For some unknown reason, it has stopped working. I went back to a previous version of the program and the same negative result.

Below is the core section of the code. Might it be that they discontinued this API???

the lsXXX variables contain the Street, city, state and Zip data

For some reason, the http address does not show completely in the code section (spaces added to prevent clickable link)

lsURLInfo = http : // api.local.yahoo.com/MapsService/V1/geocode?appid=TestGeoCode= ....

I placed "error locators" in the code and it fails trying to execute :
lsLatitude = lobjXmlDoc.documentElement.selectSingleNode("Result/Latitude").Text

Here is the code

Code:
    Dim XMLhttp    
    Dim lsURLInfo
    Dim lsTechAuthString
 
   lsURLInfo = "[URL]http://api.local.yahoo.com/MapsService/V1/geocode?appid=TestGeoCode&street[/URL]=" & lsStreet & "&city=" & lsCity & "&state=" & lsState & "&zip=" & lsZip
 
    Set XMLhttp = CreateObject("MSXML2.ServerXMLHTTP")
    XMLhttp.Open "GET", lsURLInfo, False
    XMLhttp.setRequestHeader "Content-Type", "text/xml"
    XMLhttp.send StringVal
    lsTechAuthString = XMLhttp.responseText
    Set XMLhttp = Nothing
    Set lobjXmlDoc = CreateObject("Microsoft.XMLDOM")
    lobjXmlDoc.Async = False
    lobjXmlDoc.loadXML (lsTechAuthString)
 
If lobjXmlDoc.parseError.errorCode <> 0 Then
        ' Error Reading XML Document
        lsResult = "Parse Error - Retry Transmission"
        lsMessage = lobjXmlDoc.parseError.errorCode & " - " & lobjXmlDoc.parseError.reason & " - " & lobjXmlDoc.parseError.Line
 
Else
 
    '   Retrieve relevant information from API - XML document
 
    '   ????????? PROGRAM ERROR OUT ON THE NEXT STATEMENT ???????
 
        lsLatitude = lobjXmlDoc.documentElement.selectSingleNode("Result/Latitude").Text
        lsLongitude = lobjXmlDoc.documentElement.selectSingleNode("Result/Longitude").Text
End If

I tried the following in a web browser using my zipcode (again added spaces to prevent clickable link)

http : // api.local.yahoo.com/MapsService/V1/geocode?appid=TestGeoCode&Zip=48322

It returned a rather nasty (useless?) message

<?xml version="1.0" encoding="UTF-8" ?>
- <Error xmlns="urn:yahoo:api">
The following errors were detected:
<Message>backend fetch error 403</< font>Message>

</< font>Error>

Any advice greatly appreciated

Thanks
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Thanks,

I use the new link (after getting a new Application ID), it fails on the following code:

lsZip = "48322"

Code:
    lsURLInfo = "http : // local.yahooapis.com/MapsService/V1/geocode?appid=MyAppID&street=" & lsStreet & "&city = " & lsCity & "&State = " & lsState & "&zip = " & lsZip
    Set XMLhttp = CreateObject("MSXML2.ServerXMLHTTP")
    XMLhttp.Open "GET", lsURLInfo, False
    ' -- more code
 
'  FAILS HERE when retrieving the Latitude value
   lsLatitude = lobjXmlDoc.documentElement.selectSingleNode("Result/Latitude").Text

I also tried

lsLatitude = lobjXmlDoc.documentElement.selectSingleNode("Latitude").Text


Are any of the above codes to get lsLatitude consistent with the Yahoo-sample XML code shown below?

<?xml version="1.0" encoding="UTF-8"?>


HTML:
 <?xml version="1.0" encoding="UTF-8"?>
<ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:yahoo:maps"
xsi:schemaLocation="urn:yahoo:maps http://local.yahooapis.com/MapsService/V1/GeocodeResponse.xsd">
  <Result precision="address">
<Latitude>37.416384</Latitude>
<Longitude>-122.024853</Longitude>
<Address>701 FIRST AVE</Address>
<City>SUNNYVALE</City>
<State>CA</State>
<Zip>94089-1019</Zip>
<Country>US</Country>
  </Result>
</ResultSet>

Thanks,

 
Upvote 0
Submitting the query to the web, results in

<?xml version="1.0" encoding="UTF-8" ?>
<?XML:NAMESPACE PREFIX = [default] urn:yahoo:api NS = "urn:yahoo:api" /><Error xmlns="urn:yahoo:api">[?xml version="1.0" encoding="UTF-8" ?>
- [Error xmlns="urn:yahoo:api">
The following errors were detected:
[Message>backend fetch error 403Message>

[/Error>

</Error><?xml:namespace prefix = yahoo /><yahoo:api:Error xmlns="urn:yahoo:api"></yahoo:api:Error>
<yahoo:api:Error xmlns="urn:yahoo:api"></yahoo:api:Error>
(Changed XML < so message is retained)

What is the "backend fetch error 403"

Any ideas, anyone?
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top