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
(DataFlex) 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
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp String sUrl Boolean iSuccess String sStrResp Handle hoJsonResponse String sSummaryQuery String sSummaryQueryType Integer iSummaryQueryTime Integer iSummaryNumResults Integer iSummaryOffset Integer iSummaryTotalResults Integer iSummaryFuzzyLevel Integer i Integer iCount_i String sV_type String sId String sScore String sAddressStreetNumber String sAddressStreetName String sAddressMunicipalitySubdivision String sAddressMunicipality String sAddressCountrySecondarySubdivision String sAddressCountryTertiarySubdivision String sAddressCountrySubdivision String sAddressPostalCode String sAddressExtendedPostalCode String sAddressCountryCode String sAddressCountry String sAddressCountryCodeISO3 String sAddressFreeformAddress String sAddressCountrySubdivisionName String sPositionLat String sPositionLon String sViewportTopLeftPointLat String sViewportTopLeftPointLon String sViewportBtmRightPointLat String sViewportBtmRightPointLon Integer j Integer iCount_j String sTemp1 Integer iTemp1 Boolean bTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End Set ComAccept Of hoHttp To "application/json" Move "https://atlas.microsoft.com/search/address/{$format}?subscription-key=[subscription-key]&api-version=1.0&query={$query}" To sUrl Get ComSetUrlVar Of hoHttp "format" "json" To iSuccess Get ComSetUrlVar Of hoHttp "query" "15127 NE 24th Street, Redmond, WA 98052" To iSuccess Get ComQuickGetStr Of hoHttp sUrl To sStrResp Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 <> True) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get ComLastStatus Of hoHttp To iTemp1 Showln "Response Status Code: " iTemp1 Get Create (RefClass(cComChilkatJsonObject)) To hoJsonResponse If (Not(IsComObjectCreated(hoJsonResponse))) Begin Send CreateComObject of hoJsonResponse End Get ComLoad Of hoJsonResponse sStrResp To iSuccess Set ComEmitCompact Of hoJsonResponse To False Get ComEmit Of hoJsonResponse To sTemp1 Showln sTemp1 Get ComLastStatus Of hoHttp To iTemp1 If (iTemp1 <> 200) Begin Showln "Failed." Procedure_Return End // 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 // } // } // ] // } // ] // } // Get ComStringOf Of hoJsonResponse "summary.query" To sSummaryQuery Get ComStringOf Of hoJsonResponse "summary.queryType" To sSummaryQueryType Get ComIntOf Of hoJsonResponse "summary.queryTime" To iSummaryQueryTime Get ComIntOf Of hoJsonResponse "summary.numResults" To iSummaryNumResults Get ComIntOf Of hoJsonResponse "summary.offset" To iSummaryOffset Get ComIntOf Of hoJsonResponse "summary.totalResults" To iSummaryTotalResults Get ComIntOf Of hoJsonResponse "summary.fuzzyLevel" To iSummaryFuzzyLevel Move 0 To i Get ComSizeOfArray Of hoJsonResponse "results" To iCount_i While (i < iCount_i) Set ComI Of hoJsonResponse To i Get ComStringOf Of hoJsonResponse "results[i].type" To sV_type Get ComStringOf Of hoJsonResponse "results[i].id" To sId Get ComStringOf Of hoJsonResponse "results[i].score" To sScore Get ComStringOf Of hoJsonResponse "results[i].address.streetNumber" To sAddressStreetNumber Get ComStringOf Of hoJsonResponse "results[i].address.streetName" To sAddressStreetName Get ComStringOf Of hoJsonResponse "results[i].address.municipalitySubdivision" To sAddressMunicipalitySubdivision Get ComStringOf Of hoJsonResponse "results[i].address.municipality" To sAddressMunicipality Get ComStringOf Of hoJsonResponse "results[i].address.countrySecondarySubdivision" To sAddressCountrySecondarySubdivision Get ComStringOf Of hoJsonResponse "results[i].address.countryTertiarySubdivision" To sAddressCountryTertiarySubdivision Get ComStringOf Of hoJsonResponse "results[i].address.countrySubdivision" To sAddressCountrySubdivision Get ComStringOf Of hoJsonResponse "results[i].address.postalCode" To sAddressPostalCode Get ComStringOf Of hoJsonResponse "results[i].address.extendedPostalCode" To sAddressExtendedPostalCode Get ComStringOf Of hoJsonResponse "results[i].address.countryCode" To sAddressCountryCode Get ComStringOf Of hoJsonResponse "results[i].address.country" To sAddressCountry Get ComStringOf Of hoJsonResponse "results[i].address.countryCodeISO3" To sAddressCountryCodeISO3 Get ComStringOf Of hoJsonResponse "results[i].address.freeformAddress" To sAddressFreeformAddress Get ComStringOf Of hoJsonResponse "results[i].address.countrySubdivisionName" To sAddressCountrySubdivisionName Get ComStringOf Of hoJsonResponse "results[i].position.lat" To sPositionLat Get ComStringOf Of hoJsonResponse "results[i].position.lon" To sPositionLon Get ComStringOf Of hoJsonResponse "results[i].viewport.topLeftPoint.lat" To sViewportTopLeftPointLat Get ComStringOf Of hoJsonResponse "results[i].viewport.topLeftPoint.lon" To sViewportTopLeftPointLon Get ComStringOf Of hoJsonResponse "results[i].viewport.btmRightPoint.lat" To sViewportBtmRightPointLat Get ComStringOf Of hoJsonResponse "results[i].viewport.btmRightPoint.lon" To sViewportBtmRightPointLon Move 0 To j Get ComSizeOfArray Of hoJsonResponse "results[i].entryPoints" To iCount_j While (j < iCount_j) Set ComJ Of hoJsonResponse To j Get ComStringOf Of hoJsonResponse "results[i].entryPoints[j].type" To sV_type Get ComStringOf Of hoJsonResponse "results[i].entryPoints[j].position.lat" To sPositionLat Get ComStringOf Of hoJsonResponse "results[i].entryPoints[j].position.lon" To sPositionLon Move (j + 1) To j Loop Move (i + 1) To i Loop End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.