Support Topics Documentation Slack YouTube Blog

GeoPoint in angular2

whenever I try to save a geopoint, I get an error saying _Model is not a constructor. You guys know what could help? Or some link to tutorial on geopoints in angular?

var dataStore = Backendless.Data.of(new Spot());
let spot = new Spot();
spot.name = "Test Spot";
let location = new Backendless.GeoPoint();
location.latitude = 50;
location.longitude = 14;
location.category = "testCategory";
spot.location = location;
dataStore.save(spot);

Hi Lukas

What version of JS_SDK are you using?
Please provide a minimum code snippet how you are trying to create a new GeoPoint

maybe it will help you https://backendless.com/docs/js/doc.html#geo_adding_a_geo_point

Regards, Vlad

Hi,

I am using node v7.9. I have added the snipet into the post, it is something like this:

var dataStore = Backendless.Data.of(new Spot());
let spot = new Spot();
spot.name = "Test Spot";
let location = new Backendless.GeoPoint();
location.latitude = 50;
location.longitude = 14;
location.category = "testCategory";
spot.location = location;
dataStore.save(spot);

Unfortunately you can not do it in a single call, you have to do it with 3 separated api calls

  1. save GeoPoint
  2. save Data Object
  3. establish relationship

please read this one https://backendless.com/docs/js/doc.html#related_objects

Regards, Vlad