/* Copyright (C) 2015 Apple Inc. All Rights Reserved. See LICENSE.txt for this sample’s licensing information Abstract: Sample code for performing a location query for Items objects in the public database. Includes rendering helpers. */ CKCatalog.tabs['public-query'] = (function() { var renderItem = function (name, location, assetUrl) { var item = document.createElement('div'); item.className = 'item'; // Div to clear floats. var clear = document.createElement('div'); clear.className = 'clear'; // Build the img element. var imageEl = document.createElement('img'); imageEl.src = assetUrl; imageEl.setAttribute('width', '300'); imageEl.className = 'item-asset'; // Build the name element. var nameEl = document.createElement('h1'); nameEl.className = 'item-name'; nameEl.textContent = name; // Build the location element. var locationEl = document.createElement('div'); locationEl.className = 'item-location'; var latitude = document.createElement('div'); var latitudeTitle = document.createElement('span'); latitudeTitle.className = 'item-location-title'; latitudeTitle.textContent = 'Latitude: '; latitude.appendChild(latitudeTitle); latitude.appendChild(document.createTextNode(location.latitude)); var longitude = document.createElement('div'); var longitudeTitle = document.createElement('span'); longitudeTitle.className = 'item-location-title'; longitudeTitle.textContent = 'Longitude: '; longitude.appendChild(longitudeTitle); longitude.appendChild(document.createTextNode(location.longitude)); locationEl.appendChild(latitude); locationEl.appendChild(longitude); // Append all children. item.appendChild(imageEl); item.appendChild(nameEl); item.appendChild(locationEl); item.appendChild(clear); return item; }; var render = function(title) { var content = document.createElement('div'); var heading = document.createElement('h2'); heading.textContent = title; content.appendChild(heading); return content; }; var getUsersPosition = function() { return new CloudKit.Promise(function(resolve) { var fallbackToSF = function() { var location = { latitude: 37.7833, longitude: -122.4167 }; var html = '
Using location of San Francisco instead:
' + '