Im having issue to extracting the Google Earth coordinates, because I need it to be in latlng and not GPoint, and need to expose to my Google Map app, Im aware that I can use those points to show my data in the gmap, but still need to convert to latlng, my nodejs script its
var fs = require('fs'),
xml2js = require('xml2js');
var parser = new xml2js.Parser();
fs.readFile(__dirname + '/doc.xml', function(err, data) {
parser.parseString(data, function (err, result) {
var data = [];
for (var i in result.data.Placemark) {
var row = result.data.Placemark[i];
var point = row.Point[0].coordinates.toString().split(',');
row = {
name : row.name[0]
, description : row.description[0]
, geolocation : [point[0], point[1]]
};
data.push(row);
}
console.log(data);
});
});
At this point Im able to extract all the data I want (I just removed all the unnecessary tags from the KML). But I need to normalize it to latlng because my other database documents (noSQL) are all in latlng.
Reverse the order of point[0] (longitude), point[1] (latitude).
Change:
geolocation : [point[0], point[1]]
To:
geolocation : [point[1], point[0]]