views:

69

answers:

1

hi everbody,

i'm newbie in javascript so, in this example exists the geometrycontrols.js (for global controls) and markercontrol.js (for marker controls)

my problem is identify the arrays where "data" is saved...

at the reference i see a savedata function but i have no idea how work with this function...

on the other side, in test.html if i've the outup on the Glog startup and output "data", and let me thinking that comes from array...

My objective is save the coordinates and other all atributes to mysql database, and when i discover where are "data" is the easy part.

if someone worked with this example (or not) can help me i'm grateful

ps: i'm really a newbie on javascript :P

edit1: I was out for a time, and now I focus in geometrycontrols.js specially in: 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));}; `

When I alert(recordJSON.coordinates), the outupt is [object Object] and i've no idea why, in theory this array contains the coordinates...

A: 

The data is stored in JSON format in this file: http://gmaps-utility-library-dev.googlecode.com/svn/trunk/geometrycontrols/examples/data/testdata.js -- it's pretty much self-documenting, just follow the example to set your coordinates.

Note that if you need to find the latitude and longitude for a given address this is a good site: http://itouchmap.com/latlong.html

Dan U.
hi, I analyzed the code and in part you're right the testdata.js has JSON data format, but the file is not automatically updated, when i active auto save data nothing happens...testdata.js it was made by hand and is load in map start
TiagoMartins
could you post a link to the page you're working on so we can check out what's not working?
Dan U.
hi, i'm working on private server so i can't post links to my pages, but on root http://gmaps-utility-library-dev.googlecode.com/svn/trunk/geometrycontrols/ are all pages that i'm working and in "official example" save option don't work too... so it's the same problem, and my code it's praticcly the same...
TiagoMartins
Do you have a PHP script and database set up for saving the data? I think this article on how to save data from a Google Map interface should help you out: http://code.google.com/apis/maps/articles/phpsqlinfo.html
Dan U.
hi, sorry the delay, i have the database set up like the example and i'll implement your last link to update the database, but if you see something to save in JSON data format i appreciate
TiagoMartins