0

I'm using Cloudkit JS to save data to a public database. Its easy to do when the fields are all strings. I'm stuck now trying to figure out how to save data when the field type is a CLLocation. Somehow I need to structure the JavaScript to send both latitude and longitude values.

See the ??? in the code example below;

var new record = { recordType: "Thing",
    fields: {   name: { value: "My Name" },
                description:  { value: "My Description" },
                location: { ??? }
    }
};

Does anyone know how to take the lat and long coordinates and represent them in the code above?

GoPlaces
  • 3
  • 2

1 Answers1

0

Try passing it like this:

fields: {
    location: { value: { latitude: lat, longitude: lng }, type: "LOCATION" }
}

lat and lng are Doubles, not Strings

Brian Hamm
  • 426
  • 3
  • 8