Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

MFC Web API Examples

Primary Categories

AWS Translate
Activix CRM
Adyen
Amazon MWS
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Bluzone
CardConnect
ClickBank
Clickatell
Cloudfare
DocuSign
ETrade
Etsy
Facebook
GeoOp
GetHarvest
Jira
MYOB

Magento
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Okta OAuth/OIDC
OneLogin OIDC
PayPal
Peoplevox
Populi
QuickBooks
SOAP finkok.com
Shippo
Shopify
Stripe
SugarCRM
Trello
Twitter
VoiceBase
Vonage
Walmart
Walmart v3
Xero
eBay
effectconnect

 

 

 

(MFC) Azure Maps Get Search Address

Get information for a given address.

For more information, see https://docs.microsoft.com/en-us/rest/api/maps/search/getsearchaddress

Chilkat C/C++ Library Downloads

MS Visual C/C++ Libs

See Also: Using MFC CString in Chilkat

#include <CkHttp.h>
#include <CkJsonObject.h>

void ChilkatSample(void)
    {
    CkString strOut;

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttp http;

    http.put_Accept("application/json");

    const char *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");

    const char *strResp = http.quickGetStr(url);
    if (http.get_LastMethodSuccess() != true) {
        strOut.append(http.lastErrorText());
        strOut.append("\r\n");
        SetDlgItemText(IDC_EDIT1,strOut.getUnicode());
        return;
    }

    strOut.append("Response Status Code: ");
    strOut.appendInt(http.get_LastStatus());
    strOut.append("\r\n");

    CkJsonObject jsonResponse;
    jsonResponse.Load(strResp);
    jsonResponse.put_EmitCompact(false);
    strOut.append(jsonResponse.emit());
    strOut.append("\r\n");

    if (http.get_LastStatus() != 200) {
        strOut.append("Failed.");
        strOut.append("\r\n");
        SetDlgItemText(IDC_EDIT1,strOut.getUnicode());
        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
    //           }
    //         }
    //       ]
    //     }
    //   ]
    // }
    // 

    const char *summaryQuery = 0;
    const char *summaryQueryType = 0;
    int summaryQueryTime;
    int summaryNumResults;
    int summaryOffset;
    int summaryTotalResults;
    int summaryFuzzyLevel;
    int i;
    int count_i;
    const char *v_type = 0;
    const char *id = 0;
    const char *score = 0;
    const char *addressStreetNumber = 0;
    const char *addressStreetName = 0;
    const char *addressMunicipalitySubdivision = 0;
    const char *addressMunicipality = 0;
    const char *addressCountrySecondarySubdivision = 0;
    const char *addressCountryTertiarySubdivision = 0;
    const char *addressCountrySubdivision = 0;
    const char *addressPostalCode = 0;
    const char *addressExtendedPostalCode = 0;
    const char *addressCountryCode = 0;
    const char *addressCountry = 0;
    const char *addressCountryCodeISO3 = 0;
    const char *addressFreeformAddress = 0;
    const char *addressCountrySubdivisionName = 0;
    const char *positionLat = 0;
    const char *positionLon = 0;
    const char *viewportTopLeftPointLat = 0;
    const char *viewportTopLeftPointLon = 0;
    const char *viewportBtmRightPointLat = 0;
    const char *viewportBtmRightPointLon = 0;
    int j;
    int 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.put_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.put_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;
    }



    SetDlgItemText(IDC_EDIT1,strOut.getUnicode());

    }

 

© 2000-2019 Chilkat Software, Inc. All Rights Reserved.