在Parse.com中保存时,Geopoint默认为0,0(Javascript SDK)

cod*_*ard 2 javascript parse-platform

当我尝试将GeoPoint与我的'NewLog'解析对象一起保存时,GeoPoint始终默认为0,0.使用下面的代码,locationLat和locationLong包含一个有效的地理位置,可以按预期将其保存到locationLat/Long字段中.

var locationLat = $("#locationLat").val();
var locationLong = $("#locationLong").val();
var NewLog = Parse.Object.extend("NewLog");
var newLog = new NewLog();

var locationString = locationLat + ", " + locationLong;
console.log(locationString);

var location = new Parse.GeoPoint(locationString);

newLog.set("location", location);
newLog.set("locationLat", locationLat);
newLog.set("locationLong", locationLong);
Run Code Online (Sandbox Code Playgroud)

我可以使用新的Parse.GeoPoint(-36.82655429726454,174.4372643280756); 没有任何问题,locationString的日志也看起来正确.GeoPoint似乎似乎不接受我尝试过的任何语法变体的变量.

Sat*_*jit 5

看起来GeoPoint只接受数字而不是字符串,所以你可以试试这个

var location = new Parse.GeoPoint({latitude: parseFloat(locationLat), longitude: parseFloat(locationLong)});
Run Code Online (Sandbox Code Playgroud)