Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Swift 3,4,5... Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Swift 3,4,5...) 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 Downloads for the Swift Programming Language

MAC OS X (Cocoa) Objective-C/Swift Libs

iOS Objective-C/Swift Libs

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

    let http = CkoHttp()!

    http.accept = "application/json"

    var url: String? = "https://atlas.microsoft.com/search/address/{$format}?subscription-key=[subscription-key]&api-version=1.0&query={$query}"

    http.setUrlVar("format", value: "json")
    http.setUrlVar("query", value: "15127 NE 24th Street, Redmond, WA 98052")

    var strResp: String? = http.quickGetStr(url)
    if http.lastMethodSuccess != true {
        print("\(http.lastErrorText!)")
        return
    }

    print("Response Status Code: \(http.lastStatus.intValue)")

    let jsonResponse = CkoJsonObject()!
    jsonResponse.load(strResp)
    jsonResponse.emitCompact = false
    print("\(jsonResponse.emit()!)")

    if http.lastStatus.intValue != 200 {
        print("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: String?
    var summaryQueryType: String?
    var summaryQueryTime: Int
    var summaryNumResults: Int
    var summaryOffset: Int
    var summaryTotalResults: Int
    var summaryFuzzyLevel: Int
    var i: Int
    var count_i: Int
    var v_type: String?
    var id: String?
    var score: String?
    var addressStreetNumber: String?
    var addressStreetName: String?
    var addressMunicipalitySubdivision: String?
    var addressMunicipality: String?
    var addressCountrySecondarySubdivision: String?
    var addressCountryTertiarySubdivision: String?
    var addressCountrySubdivision: String?
    var addressPostalCode: String?
    var addressExtendedPostalCode: String?
    var addressCountryCode: String?
    var addressCountry: String?
    var addressCountryCodeISO3: String?
    var addressFreeformAddress: String?
    var addressCountrySubdivisionName: String?
    var positionLat: String?
    var positionLon: String?
    var viewportTopLeftPointLat: String?
    var viewportTopLeftPointLon: String?
    var viewportBtmRightPointLat: String?
    var viewportBtmRightPointLon: String?
    var j: Int
    var count_j: Int

    summaryQuery = jsonResponse.string(of: "summary.query")
    summaryQueryType = jsonResponse.string(of: "summary.queryType")
    summaryQueryTime = jsonResponse.int(of: "summary.queryTime").intValue
    summaryNumResults = jsonResponse.int(of: "summary.numResults").intValue
    summaryOffset = jsonResponse.int(of: "summary.offset").intValue
    summaryTotalResults = jsonResponse.int(of: "summary.totalResults").intValue
    summaryFuzzyLevel = jsonResponse.int(of: "summary.fuzzyLevel").intValue
    i = 0
    count_i = jsonResponse.size(ofArray: "results").intValue
    while i < count_i {
        jsonResponse.i = i
        v_type = jsonResponse.string(of: "results[i].type")
        id = jsonResponse.string(of: "results[i].id")
        score = jsonResponse.string(of: "results[i].score")
        addressStreetNumber = jsonResponse.string(of: "results[i].address.streetNumber")
        addressStreetName = jsonResponse.string(of: "results[i].address.streetName")
        addressMunicipalitySubdivision = jsonResponse.string(of: "results[i].address.municipalitySubdivision")
        addressMunicipality = jsonResponse.string(of: "results[i].address.municipality")
        addressCountrySecondarySubdivision = jsonResponse.string(of: "results[i].address.countrySecondarySubdivision")
        addressCountryTertiarySubdivision = jsonResponse.string(of: "results[i].address.countryTertiarySubdivision")
        addressCountrySubdivision = jsonResponse.string(of: "results[i].address.countrySubdivision")
        addressPostalCode = jsonResponse.string(of: "results[i].address.postalCode")
        addressExtendedPostalCode = jsonResponse.string(of: "results[i].address.extendedPostalCode")
        addressCountryCode = jsonResponse.string(of: "results[i].address.countryCode")
        addressCountry = jsonResponse.string(of: "results[i].address.country")
        addressCountryCodeISO3 = jsonResponse.string(of: "results[i].address.countryCodeISO3")
        addressFreeformAddress = jsonResponse.string(of: "results[i].address.freeformAddress")
        addressCountrySubdivisionName = jsonResponse.string(of: "results[i].address.countrySubdivisionName")
        positionLat = jsonResponse.string(of: "results[i].position.lat")
        positionLon = jsonResponse.string(of: "results[i].position.lon")
        viewportTopLeftPointLat = jsonResponse.string(of: "results[i].viewport.topLeftPoint.lat")
        viewportTopLeftPointLon = jsonResponse.string(of: "results[i].viewport.topLeftPoint.lon")
        viewportBtmRightPointLat = jsonResponse.string(of: "results[i].viewport.btmRightPoint.lat")
        viewportBtmRightPointLon = jsonResponse.string(of: "results[i].viewport.btmRightPoint.lon")
        j = 0
        count_j = jsonResponse.size(ofArray: "results[i].entryPoints").intValue
        while j < count_j {
            jsonResponse.j = j
            v_type = jsonResponse.string(of: "results[i].entryPoints[j].type")
            positionLat = jsonResponse.string(of: "results[i].entryPoints[j].position.lat")
            positionLon = jsonResponse.string(of: "results[i].entryPoints[j].position.lon")
            j = j + 1
        }

        i = i + 1
    }


}

 

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