Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(AutoIt) Azure Maps Get Search AddressGet information for a given address. For more information, see https://docs.microsoft.com/en-us/rest/api/maps/search/getsearchaddress
; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oHttp = ObjCreate("Chilkat.Http") $oHttp.Accept = "application/json" Local $sUrl = "https://atlas.microsoft.com/search/address/{$format}?subscription-key=[subscription-key]&api-version=1.0&query={$query}" $oHttp.SetUrlVar("format","json") $oHttp.SetUrlVar("query","15127 NE 24th Street, Redmond, WA 98052") Local $strResp = $oHttp.QuickGetStr($sUrl) If ($oHttp.LastMethodSuccess <> True) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf ConsoleWrite("Response Status Code: " & $oHttp.LastStatus & @CRLF) $oJsonResponse = ObjCreate("Chilkat.JsonObject") $oJsonResponse.Load($strResp) $oJsonResponse.EmitCompact = False ConsoleWrite($oJsonResponse.Emit() & @CRLF) If ($oHttp.LastStatus <> 200) Then ConsoleWrite("Failed." & @CRLF) Exit EndIf ; Sample output... ; (See the parsing code below..) ; ; Use this online tool to generate parsing code from sample JSON: ; Generate Parsing Code from JSON ; { ; "summary": { ; "query": "15127 NE 24th Street, Redmond, WA 98052", ; "queryType": "NON_NEAR", ; "queryTime": 58, ; "numResults": 1, ; "offset": 0, ; "totalResults": 1, ; "fuzzyLevel": 1 ; }, ; "results": [ ; { ; "type": "Point Address", ; "id": "US/PAD/p0/19173426", ; "score": 14.51, ; "address": { ; "streetNumber": "15127", ; "streetName": "NE 24th St", ; "municipalitySubdivision": "Redmond", ; "municipality": "Redmond, Adelaide, Ames Lake, Avondale, Earlmount", ; "countrySecondarySubdivision": "King", ; "countryTertiarySubdivision": "Seattle East", ; "countrySubdivision": "WA", ; "postalCode": "98052", ; "extendedPostalCode": "980525544", ; "countryCode": "US", ; "country": "United States Of America", ; "countryCodeISO3": "USA", ; "freeformAddress": "15127 NE 24th St, Redmond, WA 980525544", ; "countrySubdivisionName": "Washington" ; }, ; "position": { ; "lat": 47.6308, ; "lon": -122.1385 ; }, ; "viewport": { ; "topLeftPoint": { ; "lat": 47.6317, ; "lon": -122.13983 ; }, ; "btmRightPoint": { ; "lat": 47.6299, ; "lon": -122.13717 ; } ; }, ; "entryPoints": [ ; { ; "type": "main", ; "position": { ; "lat": 47.6315, ; "lon": -122.13852 ; } ; } ; ] ; } ; ] ; } ; Local $summaryQuery Local $summaryQueryType Local $iSummaryQueryTime Local $iSummaryNumResults Local $iSummaryOffset Local $iSummaryTotalResults Local $iSummaryFuzzyLevel Local $i Local $iCount_i Local $sV_type Local $sId Local $score Local $sAddressStreetNumber Local $sAddressStreetName Local $sAddressMunicipalitySubdivision Local $sAddressMunicipality Local $sAddressCountrySecondarySubdivision Local $sAddressCountryTertiarySubdivision Local $sAddressCountrySubdivision Local $sAddressPostalCode Local $sAddressExtendedPostalCode Local $sAddressCountryCode Local $sAddressCountry Local $sAddressCountryCodeISO3 Local $sAddressFreeformAddress Local $sAddressCountrySubdivisionName Local $sPositionLat Local $sPositionLon Local $sViewportTopLeftPointLat Local $sViewportTopLeftPointLon Local $sViewportBtmRightPointLat Local $sViewportBtmRightPointLon Local $iJ Local $iCount_j $summaryQuery = $oJsonResponse.StringOf("summary.query") $summaryQueryType = $oJsonResponse.StringOf("summary.queryType") $iSummaryQueryTime = $oJsonResponse.IntOf("summary.queryTime") $iSummaryNumResults = $oJsonResponse.IntOf("summary.numResults") $iSummaryOffset = $oJsonResponse.IntOf("summary.offset") $iSummaryTotalResults = $oJsonResponse.IntOf("summary.totalResults") $iSummaryFuzzyLevel = $oJsonResponse.IntOf("summary.fuzzyLevel") $i = 0 $iCount_i = $oJsonResponse.SizeOfArray("results") While $i < $iCount_i $oJsonResponse.I = $i $sV_type = $oJsonResponse.StringOf("results[i].type") $sId = $oJsonResponse.StringOf("results[i].id") $score = $oJsonResponse.StringOf("results[i].score") $sAddressStreetNumber = $oJsonResponse.StringOf("results[i].address.streetNumber") $sAddressStreetName = $oJsonResponse.StringOf("results[i].address.streetName") $sAddressMunicipalitySubdivision = $oJsonResponse.StringOf("results[i].address.municipalitySubdivision") $sAddressMunicipality = $oJsonResponse.StringOf("results[i].address.municipality") $sAddressCountrySecondarySubdivision = $oJsonResponse.StringOf("results[i].address.countrySecondarySubdivision") $sAddressCountryTertiarySubdivision = $oJsonResponse.StringOf("results[i].address.countryTertiarySubdivision") $sAddressCountrySubdivision = $oJsonResponse.StringOf("results[i].address.countrySubdivision") $sAddressPostalCode = $oJsonResponse.StringOf("results[i].address.postalCode") $sAddressExtendedPostalCode = $oJsonResponse.StringOf("results[i].address.extendedPostalCode") $sAddressCountryCode = $oJsonResponse.StringOf("results[i].address.countryCode") $sAddressCountry = $oJsonResponse.StringOf("results[i].address.country") $sAddressCountryCodeISO3 = $oJsonResponse.StringOf("results[i].address.countryCodeISO3") $sAddressFreeformAddress = $oJsonResponse.StringOf("results[i].address.freeformAddress") $sAddressCountrySubdivisionName = $oJsonResponse.StringOf("results[i].address.countrySubdivisionName") $sPositionLat = $oJsonResponse.StringOf("results[i].position.lat") $sPositionLon = $oJsonResponse.StringOf("results[i].position.lon") $sViewportTopLeftPointLat = $oJsonResponse.StringOf("results[i].viewport.topLeftPoint.lat") $sViewportTopLeftPointLon = $oJsonResponse.StringOf("results[i].viewport.topLeftPoint.lon") $sViewportBtmRightPointLat = $oJsonResponse.StringOf("results[i].viewport.btmRightPoint.lat") $sViewportBtmRightPointLon = $oJsonResponse.StringOf("results[i].viewport.btmRightPoint.lon") $iJ = 0 $iCount_j = $oJsonResponse.SizeOfArray("results[i].entryPoints") While $iJ < $iCount_j $oJsonResponse.J = $iJ $sV_type = $oJsonResponse.StringOf("results[i].entryPoints[j].type") $sPositionLat = $oJsonResponse.StringOf("results[i].entryPoints[j].position.lat") $sPositionLon = $oJsonResponse.StringOf("results[i].entryPoints[j].position.lon") $iJ = $iJ + 1 Wend $i = $i + 1 Wend |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.