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

Geopoint defaults to 0,0 when saving in Parse.com (Javascript SDK)

本文关键字:Geopoint 默认 保存 com Parse Javascript SDK      更新时间:2023-09-26

当我试图将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);

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

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

var location = new Parse.GeoPoint({latitude: parseFloat(locationLat), longitude: parseFloat(locationLong)});