2013-08-30 56 views
1

當我嘗試將GeoPoint和我的'NewLog'分析對象一起保存時,GeoPoint始終默認爲0,0。使用下面的代碼,locationLat和locationLong包含一個有效的地理位置,可按預期將其保存到locationLat/Long字段中。在Parse.com(JavaScript SDK)中保存時,Geopoint默認爲0,0

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.82655429726454,174.4372643280756);沒有任何問題,並且locationString的日誌也看起來正確。 GeoPoint似乎並沒有接受任何我嘗試過的語法變體的變量。

回答

4

貌似GeoPoint對象只接受數&不是字符串,那麼你可以試試這個

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