Creating a location object in CloudKit JS

How do I create a location object in Cloudkit JS? I'm assuming I'm using the right terminology here.


Below is me creating the record object - you can see the place holder for location there.

Separate I have latitude and longitude.



var record = {
recordType: "Camera",
fields: {
          title: { value: self.newCameraTitle() },
          url: { value: self.newCameraURL() },
          location: { value: location }
         }
};


This specifies the contens and mandatory items... I'd need to know how to create the location object.

https://developer.apple.com/library/ios/documentation/DataManagement/Conceptual/CloutKitWebServicesReference/Types/Types.html#//apple_ref/doc/uid/TP40015240-CH3-SW14


My attempt at this has been unsuccessful.

var location = {
recordType: "location",
fields: {
          latitude: {value: self.newCameraLatitude()},
          longitude: {value: self.newCameraLongitude()}
         }
};


- David

Replies

And I'm looking for something that ends up like:


location: Object
type: "LOCATION"
value: {latitude: -41.203, longitude: 174.907, horizontalAccuracy: 0, altitude: 0, verticalAccuracy: -1, …}


I currently have this - which also does not work:

var location = {
type: "LOCATION",
value: {
latitude: {value: self.newCameraLatitude()},
longitude: {value: self.newCameraLongitude()}
}
};


- David

This seems to work.


var location = {
    latitude: self.newCameraLatitude(),
    longitude: self.newCameraLongitude()
};


// "reason": "invalid attempt to use latitude outside valid range of -90.0 to 90.0"


Note my commented out error message. Not sure how these sorts of coordinates will be handled.. "151.422404,-33.228646" yet. More investigation required.


- David