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
(Node.js) 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
var os = require('os'); if (os.platform() == 'win32') { if (os.arch() == 'ia32') { var chilkat = require('@chilkat/ck-node21-win-ia32'); } else { var chilkat = require('@chilkat/ck-node21-win64'); } } else if (os.platform() == 'linux') { if (os.arch() == 'arm') { var chilkat = require('@chilkat/ck-node21-arm'); } else if (os.arch() == 'x86') { var chilkat = require('@chilkat/ck-node21-linux32'); } else { var chilkat = require('@chilkat/ck-node21-linux64'); } } else if (os.platform() == 'darwin') { if (os.arch() == 'arm64') { var chilkat = require('@chilkat/ck-node21-mac-m1'); } else { var chilkat = require('@chilkat/ck-node21-macosx'); } } function chilkatExample() { // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. var http = new chilkat.Http(); http.Accept = "application/json"; var url = "https://atlas.microsoft.com/search/address/{$format}?subscription-key=[subscription-key]&api-version=1.0&query={$query}"; http.SetUrlVar("format","json"); http.SetUrlVar("query","15127 NE 24th Street, Redmond, WA 98052"); var strResp = http.QuickGetStr(url); if (http.LastMethodSuccess !== true) { console.log(http.LastErrorText); return; } console.log("Response Status Code: " + http.LastStatus); var jsonResponse = new chilkat.JsonObject(); jsonResponse.Load(strResp); jsonResponse.EmitCompact = false; console.log(jsonResponse.Emit()); if (http.LastStatus !== 200) { console.log("Failed."); return; } // 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 // } // } // ] // } // ] // } // var summaryQuery; var summaryQueryType; var summaryQueryTime; var summaryNumResults; var summaryOffset; var summaryTotalResults; var summaryFuzzyLevel; var i; var count_i; var v_type; var id; var score; var addressStreetNumber; var addressStreetName; var addressMunicipalitySubdivision; var addressMunicipality; var addressCountrySecondarySubdivision; var addressCountryTertiarySubdivision; var addressCountrySubdivision; var addressPostalCode; var addressExtendedPostalCode; var addressCountryCode; var addressCountry; var addressCountryCodeISO3; var addressFreeformAddress; var addressCountrySubdivisionName; var positionLat; var positionLon; var viewportTopLeftPointLat; var viewportTopLeftPointLon; var viewportBtmRightPointLat; var viewportBtmRightPointLon; var j; var count_j; summaryQuery = jsonResponse.StringOf("summary.query"); summaryQueryType = jsonResponse.StringOf("summary.queryType"); summaryQueryTime = jsonResponse.IntOf("summary.queryTime"); summaryNumResults = jsonResponse.IntOf("summary.numResults"); summaryOffset = jsonResponse.IntOf("summary.offset"); summaryTotalResults = jsonResponse.IntOf("summary.totalResults"); summaryFuzzyLevel = jsonResponse.IntOf("summary.fuzzyLevel"); i = 0; count_i = jsonResponse.SizeOfArray("results"); while (i < count_i) { jsonResponse.I = i; v_type = jsonResponse.StringOf("results[i].type"); id = jsonResponse.StringOf("results[i].id"); score = jsonResponse.StringOf("results[i].score"); addressStreetNumber = jsonResponse.StringOf("results[i].address.streetNumber"); addressStreetName = jsonResponse.StringOf("results[i].address.streetName"); addressMunicipalitySubdivision = jsonResponse.StringOf("results[i].address.municipalitySubdivision"); addressMunicipality = jsonResponse.StringOf("results[i].address.municipality"); addressCountrySecondarySubdivision = jsonResponse.StringOf("results[i].address.countrySecondarySubdivision"); addressCountryTertiarySubdivision = jsonResponse.StringOf("results[i].address.countryTertiarySubdivision"); addressCountrySubdivision = jsonResponse.StringOf("results[i].address.countrySubdivision"); addressPostalCode = jsonResponse.StringOf("results[i].address.postalCode"); addressExtendedPostalCode = jsonResponse.StringOf("results[i].address.extendedPostalCode"); addressCountryCode = jsonResponse.StringOf("results[i].address.countryCode"); addressCountry = jsonResponse.StringOf("results[i].address.country"); addressCountryCodeISO3 = jsonResponse.StringOf("results[i].address.countryCodeISO3"); addressFreeformAddress = jsonResponse.StringOf("results[i].address.freeformAddress"); addressCountrySubdivisionName = jsonResponse.StringOf("results[i].address.countrySubdivisionName"); positionLat = jsonResponse.StringOf("results[i].position.lat"); positionLon = jsonResponse.StringOf("results[i].position.lon"); viewportTopLeftPointLat = jsonResponse.StringOf("results[i].viewport.topLeftPoint.lat"); viewportTopLeftPointLon = jsonResponse.StringOf("results[i].viewport.topLeftPoint.lon"); viewportBtmRightPointLat = jsonResponse.StringOf("results[i].viewport.btmRightPoint.lat"); viewportBtmRightPointLon = jsonResponse.StringOf("results[i].viewport.btmRightPoint.lon"); j = 0; count_j = jsonResponse.SizeOfArray("results[i].entryPoints"); while (j < count_j) { jsonResponse.J = j; v_type = jsonResponse.StringOf("results[i].entryPoints[j].type"); positionLat = jsonResponse.StringOf("results[i].entryPoints[j].position.lat"); positionLon = jsonResponse.StringOf("results[i].entryPoints[j].position.lon"); j = j+1; } i = i+1; } } chilkatExample(); |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.