我想将电线杆和电缆从我们的数据库导出到 Google 地球的 KML 文件中。
对于每个节点,我们都有一个杆阵列,电缆始终连接到阵列中的下一个杆。
导出简单路径似乎很容易。但这些路径只是显示一条路径,它们并没有显示每个路径点(电线杆)。
如果您想要每个极点的路径和点(也称为路径点),那么您需要 KML 不仅包含线段,还包含每个极点位置的单独点。
您的 KML 需要采用如下结构,其中 pollSyle 将具有一个IconStyle,其中包含您想要的点图标,而 lineStyle 将是一条粗绿线
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Style id="poleStyle">
...
</Style>
<Style id="lineStyle">
...
</Style>
<Placemark>
<styleUrl>#lineStyle</styleUrl>
<LineString>
<coordinates>...</coordinates>
</LineString>
</Placemark>
<Placemark>
<name>pole1</name>
<description>address pole1</description>
<styleUrl>#poleStyle</styleUrl>
<Point>
<coordinates>...</coordinates>
</Point>
</Placemark>
...
</Document>
</kml>
Run Code Online (Sandbox Code Playgroud)
如果您不想或不需要每个点都有唯一的名称或描述,那么您可以将这些点组合在MultiGeometry内的单个地标中,如下所示:
<Placemark>
<styleUrl>#poleStyle</styleUrl>
<MultiGeometry>
<Point>
<coordinates>...</coordinates>
</Point>
<Point>
<coordinates>...</coordinates>
</Point>
</MultiGeometry>
</Placemark>
Run Code Online (Sandbox Code Playgroud)