我确定这是我做的蠢事,但我无法理解。我正在尝试从头开始编写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);
}
}
答案 0 :(得分:0)
我不确定这是否是原因,但您可以尝试在KML文件中添加文档并将该文档指定为kml.Feature并使用.AddFeature(文件夹)将您的功能添加到此文档中; 这样对我有用