我确定这是我在做的愚蠢的事情,但我无法弄清楚。我正在尝试从头开始编写 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);
}
}