简体   繁体   English

从Google Earth KML文件指向latlng转换

[英]Point to latlng conversion from Google Earth KML file

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 我在提取Google Earth坐标时遇到问题,因为我需要将其放置在latlng中而不是GPoint中,并且需要向我的Google Map应用公开,我知道我可以使用这些点在gmap中显示我的数据,但是需要转换为latlng,我的nodejs脚本

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). 此时,我可以提取所需的所有数据(我刚刚从KML中删除了所有不必要的标签)。 But I need to normalize it to latlng because my other database documents (noSQL) are all in latlng. 但是我需要将其标准化为latlng,因为我的其他数据库文档(noSQL)都在latlng中。

Reverse the order of point[0] (longitude), point[1] (latitude). 颠倒点[0](经度),点[1](纬度)的顺序。

Change: 更改:

    geolocation   : [point[0], point[1]]

To: 至:

    geolocation   : [point[1], point[0]]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 允许下载通过JavaScript和Google Earth API创建的KML文件 - Allow download of KML file created from JavaScript and Google Earth API 无法在Google地球中渲染kml文件 - Unable to render kml file in google earth 在Google Earth API KML文件中搜索String Value placemarker? - Search String Value placemarker in Google Earth API KML File? 解析kml文件以在Google地球中显示多个地标 - Parse kml file to show multiple Placemark in google earth Google Earth浏览器插件未在某些浏览器中加载KML文件 - Google Earth Browser Plugin not loading KML file in some browsers 访问和更改已加载的KML文件中的对象(Google Earth插件) - Accessing and altering objects in a loaded KML file (google earth plugin) javascript-如何在Google Earth中设置kml文件的动画范围 - javascript-how to set the animation range of kml file in google earth Google Maps呈现Google Earth的KML逆 - Google Maps Renders KML inverse of Google Earth 从LatLng计算LatLng距离(或指向圆圈) - Google Maps v3 - Work out LatLng distance from LatLng (or point in circle) - Google Maps v3 NetworkLink kml文件可在Google Earth中使用,但不能在Google地图上使用(浏览器地图只是没有任何地标的裸机地图) - NetworkLink kml file works in Google earth but not on Google maps (the browser map is just a bare map without any placemarks)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM