我是新手在JavaScript,因此在這種example存在geometrycontrols.js(全球控制)和markercontrol.js(用於標示控制)JavaScript數組
我的問題是識別陣列,其中「數據「保存...
在引用我看到一個SAVEDATA功能,但我不知道如何使用此功能工作...
在另一邊,在test.html中如果我的outup在Glog的啓動和輸出「數據」,並讓我想到來自陣列...
我的目標是將座標和其他所有屬性保存到mysql數據庫,並且當我發現「數據」是哪裏的簡單部分時。
,如果有人用這個例子中工作(或沒有)能夠幫助我,我很感激
PS:我真的在JavaScript中的新手:P
EDIT1: 我出去時間,現在我專注於geometrycontrols.js特別是在:GeometryControls.prototype.saveData = function(opts){ var me = this; if(opts.allData === true){ //me.saveAllData(); } else { //construct a json data record var geomInfo = opts.geomInfo, index = opts.geomInfo.index; var record = geomInfo.storage[index];
var recordJSON = {}; recordJSON.type = record.type; recordJSON.coordinates = [];
//determine geometry type, and copy geometry appropriately
if(record.type === "point"){
recordJSON.coordinates.push({lat:record.geometry.getLatLng().lat(),lng:record.geometry.getLatLng().lng()});
alert(recordJSON.coordinates);
} else {
alert("is not point");
var vertex;
for(var i=0;i<record.geometry.getVertexCount();i++){
vertex = record.geometry.getVertex(i);
recordJSON.coordinates.push({lat:vertex.lat(),lng:vertex.lng()});
}
}
//add title and description
recordJSON.title = record.title[0];
recordJSON.description = record.description[0];
//TODO add styles
recordJSON.style = ""; //TODO} //TODO Make separate prototype function?function postData(data){
//TODO
me.debug(data);
//alert(recordJSON.coordinates);
//alert(data);
};postData(me.serialize(recordJSON));}; `
當我提醒(recordJSON.coordinates),該outupt爲[對象對象],我已經不知道爲什麼,在理論上這數組包含座標...
嗨,我分析了代碼,部分你是對的testdata.js有JSON數據格式,但該文件不會自動更新,當我主動自動保存數據時什麼也沒有發生...... testdata.js它是手工製作並載入地圖開始 – TiagoMartins 2010-06-21 16:46:03
您能否發佈一個鏈接到您正在處理的頁面,以便我們查看哪些內容無效? – 2010-06-21 16:59:58
嗨,我在私人服務器上工作,所以我不能發佈鏈接到我的網頁,但在根http://gmaps-utility-library-dev.googlecode.com/svn/trunk/geometrycontrols/是所有頁面我正在工作,並在「官方示例」保存選項不工作太...所以這是同樣的問題,我的代碼它普遍相同... – TiagoMartins 2010-06-22 15:05:58