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
(Visual FoxPro) 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
LOCAL loHttp LOCAL lcUrl LOCAL lcStrResp LOCAL loJsonResponse LOCAL lcSummaryQuery LOCAL lcSummaryQueryType LOCAL lnSummaryQueryTime LOCAL lnSummaryNumResults LOCAL lnSummaryOffset LOCAL lnSummaryTotalResults LOCAL lnSummaryFuzzyLevel LOCAL i LOCAL lnCount_i LOCAL lcV_type LOCAL lcId LOCAL lcScore LOCAL lcAddressStreetNumber LOCAL lcAddressStreetName LOCAL lcAddressMunicipalitySubdivision LOCAL lcAddressMunicipality LOCAL lcAddressCountrySecondarySubdivision LOCAL lcAddressCountryTertiarySubdivision LOCAL lcAddressCountrySubdivision LOCAL lcAddressPostalCode LOCAL lcAddressExtendedPostalCode LOCAL lcAddressCountryCode LOCAL lcAddressCountry LOCAL lcAddressCountryCodeISO3 LOCAL lcAddressFreeformAddress LOCAL lcAddressCountrySubdivisionName LOCAL lcPositionLat LOCAL lcPositionLon LOCAL lcViewportTopLeftPointLat LOCAL lcViewportTopLeftPointLon LOCAL lcViewportBtmRightPointLat LOCAL lcViewportBtmRightPointLon LOCAL j LOCAL lnCount_j * This example requires the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.Http') loHttp.Accept = "application/json" lcUrl = "https://atlas.microsoft.com/search/address/{$format}?subscription-key=[subscription-key]&api-version=1.0&query={$query}" loHttp.SetUrlVar("format","json") loHttp.SetUrlVar("query","15127 NE 24th Street, Redmond, WA 98052") lcStrResp = loHttp.QuickGetStr(lcUrl) IF (loHttp.LastMethodSuccess <> 1) THEN ? loHttp.LastErrorText RELEASE loHttp CANCEL ENDIF ? "Response Status Code: " + STR(loHttp.LastStatus) * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJsonResponse = CreateObject('Chilkat.JsonObject') loJsonResponse.Load(lcStrResp) loJsonResponse.EmitCompact = 0 ? loJsonResponse.Emit() IF (loHttp.LastStatus <> 200) THEN ? "Failed." RELEASE loHttp RELEASE loJsonResponse CANCEL 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 * } * } * ] * } * ] * } * lcSummaryQuery = loJsonResponse.StringOf("summary.query") lcSummaryQueryType = loJsonResponse.StringOf("summary.queryType") lnSummaryQueryTime = loJsonResponse.IntOf("summary.queryTime") lnSummaryNumResults = loJsonResponse.IntOf("summary.numResults") lnSummaryOffset = loJsonResponse.IntOf("summary.offset") lnSummaryTotalResults = loJsonResponse.IntOf("summary.totalResults") lnSummaryFuzzyLevel = loJsonResponse.IntOf("summary.fuzzyLevel") i = 0 lnCount_i = loJsonResponse.SizeOfArray("results") DO WHILE i < lnCount_i loJsonResponse.I = i lcV_type = loJsonResponse.StringOf("results[i].type") lcId = loJsonResponse.StringOf("results[i].id") lcScore = loJsonResponse.StringOf("results[i].score") lcAddressStreetNumber = loJsonResponse.StringOf("results[i].address.streetNumber") lcAddressStreetName = loJsonResponse.StringOf("results[i].address.streetName") lcAddressMunicipalitySubdivision = loJsonResponse.StringOf("results[i].address.municipalitySubdivision") lcAddressMunicipality = loJsonResponse.StringOf("results[i].address.municipality") lcAddressCountrySecondarySubdivision = loJsonResponse.StringOf("results[i].address.countrySecondarySubdivision") lcAddressCountryTertiarySubdivision = loJsonResponse.StringOf("results[i].address.countryTertiarySubdivision") lcAddressCountrySubdivision = loJsonResponse.StringOf("results[i].address.countrySubdivision") lcAddressPostalCode = loJsonResponse.StringOf("results[i].address.postalCode") lcAddressExtendedPostalCode = loJsonResponse.StringOf("results[i].address.extendedPostalCode") lcAddressCountryCode = loJsonResponse.StringOf("results[i].address.countryCode") lcAddressCountry = loJsonResponse.StringOf("results[i].address.country") lcAddressCountryCodeISO3 = loJsonResponse.StringOf("results[i].address.countryCodeISO3") lcAddressFreeformAddress = loJsonResponse.StringOf("results[i].address.freeformAddress") lcAddressCountrySubdivisionName = loJsonResponse.StringOf("results[i].address.countrySubdivisionName") lcPositionLat = loJsonResponse.StringOf("results[i].position.lat") lcPositionLon = loJsonResponse.StringOf("results[i].position.lon") lcViewportTopLeftPointLat = loJsonResponse.StringOf("results[i].viewport.topLeftPoint.lat") lcViewportTopLeftPointLon = loJsonResponse.StringOf("results[i].viewport.topLeftPoint.lon") lcViewportBtmRightPointLat = loJsonResponse.StringOf("results[i].viewport.btmRightPoint.lat") lcViewportBtmRightPointLon = loJsonResponse.StringOf("results[i].viewport.btmRightPoint.lon") j = 0 lnCount_j = loJsonResponse.SizeOfArray("results[i].entryPoints") DO WHILE j < lnCount_j loJsonResponse.J = j lcV_type = loJsonResponse.StringOf("results[i].entryPoints[j].type") lcPositionLat = loJsonResponse.StringOf("results[i].entryPoints[j].position.lat") lcPositionLon = loJsonResponse.StringOf("results[i].entryPoints[j].position.lon") j = j + 1 ENDDO i = i + 1 ENDDO RELEASE loHttp RELEASE loJsonResponse |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.