2

When I attempt to save a GeoPoint along with my 'NewLog' Parse Object, the GeoPoint always defaults to 0,0. Using the below code the locationLat and locationLong contains a valid geolocation which saves as expected into the locationLat/Long fields.

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);

I can use new Parse.GeoPoint(-36.82655429726454, 174.4372643280756); without any problems, and the log for locationString also looks correct. The GeoPoint just doesn't seem to accept a variable with any variation of syntax I've tried.

4

1 回答 1

5

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

var location = new Parse.GeoPoint({latitude: parseFloat(locationLat), longitude: parseFloat(locationLong)});
于 2013-08-30T22:39:37.333 回答