接前面一篇日志《在google地图上显示路线》,我们觉得替换官方KML文件中的坐标值的做法太low了,因此在这篇文章会介绍如何用C#自动生成google map engine所支持的kml文件。
让我们再来回顾一下上一篇所提到的用于生成路径的官方KML文件。为了方便阅读,下面的版本是缩减过后的。
<?xml version="1.0" encoding="UTF-8"?>将上面的kml文件用KML Notepad打开可以看到该文件中所有节点的树形关系,如下图<kml xmlns="http://www.opengis.net/kml/2.2"><Document> <name>Paths</name> <description>Examples of paths.</description> <Style id="yellowLineGreenPoly"> <LineStyle> <color>7f00ffff</color> <width>4</width> </LineStyle> <PolyStyle> <color>7f00ff00</color> </PolyStyle> </Style> <Placemark> <name>Absolute Extruded</name> <description>Transparent green wall with yellow outlines</description> <styleUrl>#yellowLineGreenPoly</styleUrl> <LineString> <extrude>1</extrude> <tessellate>1</tessellate> <altitudeMode>absolute</altitudeMode> <coordinates> -112.2550785337791,36.07954952145647,2357 -112.2549277039738,36.08117083492122,2357 </coordinates> </LineString> </Placemark> </Document> </kml>