0

我确定这是我在做的愚蠢的事情,但我无法弄清楚。我正在尝试从头开始编写 KML。它将在一个 KMZ 内,里面有一堆地理参考图片,我不会显示为照片叠加层。虽然我无法编写 KML,但我发现文档太基本而无法合并文件夹。当我暂停程序并调试时,它显示 Kml kml 没有子级,但功能“文件夹”有 42 个。然后命名空间没有出现,也没有写入 Kml 文件。拜托,你可以给我任何帮助!

public void WriteKML_sharp()
    {

        Kml kml = new Kml();

        kml.AddNamespacePrefix(KmlNamespaces.GX22Prefix, KmlNamespaces.GX22Namespace);

        Folder folder = new Folder();
        kml.Feature = folder;
        foreach (Picture picture in _process.pictures)
        {
            PhotoOverlay photooverlay = new PhotoOverlay();

            photooverlay.Name = picture.name + picture.extension;
            photooverlay.Open = true;
            photooverlay.Shape = Shape.Rectangle;

            Icon icon = new Icon();
            Uri uri = new Uri(Path.Combine("files", picture.name + picture.extension), UriKind.Relative);
            icon.Href = uri;
            photooverlay.Icon = icon;

            Point point = new Point();
            point.Coordinate = new Vector(picture.gpslat, picture.gpslong);
            //point.Coordinate = new Vector(picture.gpslat, picture.gpslong, picture.gpsalt);
            point.AltitudeMode = AltitudeMode.RelativeToGround;
            photooverlay.Location = point;

            ViewVolume viewvolume = new ViewVolume();
            viewvolume.Top = 25;
            viewvolume.Bottom = -25;
            viewvolume.Left = 20;
            viewvolume.Right = -20;
            photooverlay.View = viewvolume;

            folder.AddFeature(photooverlay);
        }

        KmlFile kmlfile = KmlFile.Create(kml, false);
        using (var stream = System.IO.File.OpenWrite(_filename))
        {
            kmlfile.Save(stream);
        }

    }
4

1 回答 1

0

我不确定这是否是原因,但您可以尝试在 KML 文件中添加文档并将该文档指定为 kml.Feature 并使用 .AddFeature(folder); 将您的功能添加到此文档;它对我有用

于 2017-04-25T06:27:18.283 回答