Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

API Call to return map of 5 closest hospitals of an address 1

Status
Not open for further replies.

Swi

Programmer
Feb 4, 2002
1,963
US
Does anyone have any recommendations for an API that will return a map image of the 5 closest hospitals based on an address?

Thanks.

Swi
 
Should be able top do it with the Bing Maps REST API, returning a map to a webc ontrol on a VB6 form. Covered some of this in <fx: google ...> ... thread222-1807492
 
Thanks, I will have to take a look.

Swi
 
Are webcontrols for VB6 limited to MSIE, which is also on its death bed?
 
The IE desktop application and SHDoVw dll that power the webcontrols are two different things. Whilst the IE application may be dying next year (indeed, the now-released W11 does not include an enabled version of IE), the SHDocVW components are considered an OS component, and thus supported up to the EOL of the OS they are included with. As they are included in Windows 11, they are supported until at least the EOL of that OS
 
Thanks. My concern extends beyond whether the latest OS supports IE and this dll. There is lessening support by web services for compatibility with IE.
 
strongm,

When running your test code in the link above I keep getting an error:

Object variable or With block variable not set.

Any ideas?

Swi
 
Which bit of code? There a several... And they are interrelated. Are you sure you followed all the prerequisites for each bit?
 
Hi strongm,

Apologies, I found my error and it is working great now. Thanks again.

Swi
 
Thanks strongm. I will take a look at that one as well. I think they may want a wider radius but maybe I can talk them into the 5km radius. Thanks again.

Swi
 
Hi,

Ok, I have the call working and returning but the XML is something I am having issues parsing. Any ideas

Code:
    APICall = "[URL unfurl="true"]https://dev.virtualearth.net/REST/v1/LocalSearch/"[/URL]
    Query = "?type=Hospitals&maxResults=5&userLocation=47.602038,-122.333964,8046.72&o=xml"
    strKey = "&key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
    
        Set oxmlhttp2 = New MSXML2.ServerXMLHTTP60
        oxmlhttp2.Open "get", APICall & Query & strKey, False
        oxmlhttp2.setRequestHeader "Content-Type", "application/x-[URL unfurl="true"]www-form-urlencoded"[/URL]
        oxmlhttp2.send sRequest
        Set oXMLDoc2 = New MSXML2.DOMDocument60
        oXMLDoc2.async = False
        If oxmlhttp2.readyState = 4 Or oxmlhttp2.Status = 200 Then
          result = oXMLDoc2.loadXML(oxmlhttp2.responseText)
          Text1.Text = oxmlhttp2.responseText
        Else
          result = False
        End If
        MsgBox oXMLDoc2.xml
        'Get a nodelist
        Set objNodelist = oXMLDoc2.selectNodes("//Response/ResourceSets/ResourceSet/Resources/Resource")
        
        'Loop through the nodelist and pull the vaules you need
        For Each objNode In objNodelist
            MsgBox objNode.selectSingleNode("Name").Text
            MsgBox objNode.selectSingleNode("Point").Text
        Next objNode
        
        'Cleanup
        Set objNodelist = Nothing

Swi
 
This is working. The namespaces were wreaking havoc with the parser is what I have come to conclude as once I replaced them all was well. I am sure there is a more eloquent way of doing this.

Code:
        If oxmlhttp2.readyState = 4 Or oxmlhttp2.Status = 200 Then
          result = oXMLDoc2.loadXML(oxmlhttp2.responseText)
        Else
          result = False
        End If
        XMLStr = oXMLDoc2.xml
        XMLStr = Replace(XMLStr, " xmlns:xsd=" & Chr(34) & "[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL] & Chr(34), "")
        XMLStr = Replace(XMLStr, " xmlns:xsi=" & Chr(34) & "[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] & Chr(34), "")
        XMLStr = Replace(XMLStr, " xmlns=" & Chr(34) & "[URL unfurl="true"]http://schemas.microsoft.com/search/local/ws/rest/v1"[/URL] & Chr(34), "")
        XMLStr = Replace(XMLStr, " xsi:type=" & Chr(34) & "SearchResult" & Chr(34), "")
        oXMLDoc2.loadXML XMLStr
        Set node = oXMLDoc2.selectSingleNode("//Response/ResourceSets/ResourceSet/EstimatedTotal")
        MsgBox node.Text ' How many were returned out of 5 max results
        Set nodes = oXMLDoc2.selectNodes("//Response/ResourceSets/ResourceSet/Resources/Resource")
        For Each node In nodes
            MsgBox node.selectSingleNode("Name").Text ' Hospital Name
            MsgBox node.selectSingleNode("Point/Latitude").Text ' Hospital Latitude
            MsgBox node.selectSingleNode("Point/Longitude").Text ' Hospital Longitude
        Next

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top