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
(Tcl) 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
load ./chilkat.dll # This example requires the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set http [new_CkHttp] CkHttp_put_Accept $http "application/json" set url "https://atlas.microsoft.com/search/address/{$format}?subscription-key=[subscription-key]&api-version=1.0&query={$query}" CkHttp_SetUrlVar $http "format" "json" CkHttp_SetUrlVar $http "query" "15127 NE 24th Street, Redmond, WA 98052" set strResp [CkHttp_quickGetStr $http $url] if {[CkHttp_get_LastMethodSuccess $http] != 1} then { puts [CkHttp_lastErrorText $http] delete_CkHttp $http exit } puts "Response Status Code: [CkHttp_get_LastStatus $http]" set jsonResponse [new_CkJsonObject] CkJsonObject_Load $jsonResponse $strResp CkJsonObject_put_EmitCompact $jsonResponse 0 puts [CkJsonObject_emit $jsonResponse] if {[CkHttp_get_LastStatus $http] != 200} then { puts "Failed." delete_CkHttp $http delete_CkJsonObject $jsonResponse exit } # 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 # } # } # ] # } # ] # } # set summaryQuery [CkJsonObject_stringOf $jsonResponse "summary.query"] set summaryQueryType [CkJsonObject_stringOf $jsonResponse "summary.queryType"] set summaryQueryTime [CkJsonObject_IntOf $jsonResponse "summary.queryTime"] set summaryNumResults [CkJsonObject_IntOf $jsonResponse "summary.numResults"] set summaryOffset [CkJsonObject_IntOf $jsonResponse "summary.offset"] set summaryTotalResults [CkJsonObject_IntOf $jsonResponse "summary.totalResults"] set summaryFuzzyLevel [CkJsonObject_IntOf $jsonResponse "summary.fuzzyLevel"] set i 0 set count_i [CkJsonObject_SizeOfArray $jsonResponse "results"] while {$i < $count_i} { CkJsonObject_put_I $jsonResponse $i set v_type [CkJsonObject_stringOf $jsonResponse "results[i].type"] set id [CkJsonObject_stringOf $jsonResponse "results[i].id"] set score [CkJsonObject_stringOf $jsonResponse "results[i].score"] set addressStreetNumber [CkJsonObject_stringOf $jsonResponse "results[i].address.streetNumber"] set addressStreetName [CkJsonObject_stringOf $jsonResponse "results[i].address.streetName"] set addressMunicipalitySubdivision [CkJsonObject_stringOf $jsonResponse "results[i].address.municipalitySubdivision"] set addressMunicipality [CkJsonObject_stringOf $jsonResponse "results[i].address.municipality"] set addressCountrySecondarySubdivision [CkJsonObject_stringOf $jsonResponse "results[i].address.countrySecondarySubdivision"] set addressCountryTertiarySubdivision [CkJsonObject_stringOf $jsonResponse "results[i].address.countryTertiarySubdivision"] set addressCountrySubdivision [CkJsonObject_stringOf $jsonResponse "results[i].address.countrySubdivision"] set addressPostalCode [CkJsonObject_stringOf $jsonResponse "results[i].address.postalCode"] set addressExtendedPostalCode [CkJsonObject_stringOf $jsonResponse "results[i].address.extendedPostalCode"] set addressCountryCode [CkJsonObject_stringOf $jsonResponse "results[i].address.countryCode"] set addressCountry [CkJsonObject_stringOf $jsonResponse "results[i].address.country"] set addressCountryCodeISO3 [CkJsonObject_stringOf $jsonResponse "results[i].address.countryCodeISO3"] set addressFreeformAddress [CkJsonObject_stringOf $jsonResponse "results[i].address.freeformAddress"] set addressCountrySubdivisionName [CkJsonObject_stringOf $jsonResponse "results[i].address.countrySubdivisionName"] set positionLat [CkJsonObject_stringOf $jsonResponse "results[i].position.lat"] set positionLon [CkJsonObject_stringOf $jsonResponse "results[i].position.lon"] set viewportTopLeftPointLat [CkJsonObject_stringOf $jsonResponse "results[i].viewport.topLeftPoint.lat"] set viewportTopLeftPointLon [CkJsonObject_stringOf $jsonResponse "results[i].viewport.topLeftPoint.lon"] set viewportBtmRightPointLat [CkJsonObject_stringOf $jsonResponse "results[i].viewport.btmRightPoint.lat"] set viewportBtmRightPointLon [CkJsonObject_stringOf $jsonResponse "results[i].viewport.btmRightPoint.lon"] set j 0 set count_j [CkJsonObject_SizeOfArray $jsonResponse "results[i].entryPoints"] while {$j < $count_j} { CkJsonObject_put_J $jsonResponse $j set v_type [CkJsonObject_stringOf $jsonResponse "results[i].entryPoints[j].type"] set positionLat [CkJsonObject_stringOf $jsonResponse "results[i].entryPoints[j].position.lat"] set positionLon [CkJsonObject_stringOf $jsonResponse "results[i].entryPoints[j].position.lon"] set j [expr $j + 1] } set i [expr $i + 1] } delete_CkHttp $http delete_CkJsonObject $jsonResponse |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.