首页 > 解决方案 > 在 Google 地球中显示带有原点和方向的矢量

问题描述

想要在 Google 地球中定义的位置显示方向矢量。在 3D 工具中,方向矢量不同于位置矢量(即通过一条线连接的 2 个地理点),其显示大小与缩放级别无关,仅取决于纵横角(投影)。

Side mote:最后我想显示跨越正交坐标系的 3 个方向向量。所以每个“向量”都会指向 3D 空间。

有任何解决方案吗?或者任何解决方法的想法?

我熟悉 KML,并且已经实现了我的第一个目标,即显示地面轨迹并使用多边形突出显示感兴趣的区域。但是我没有找到我的请求的解决方案。

标签: kmlgoogle-earth

解决方案


您可以使用看起来像箭头的图标图像创建点,并使用适当的标签旋转它们,如下面的 KML 所示。尝试将其复制/粘贴到地球专业版中。

请注意,在此示例中,我使用了一个易于使用的图标,其中箭头指向下方,但您可能希望在箭头指向上方的位置使用您自己的图标,以便图标标题与指南针角度匹配。此外,您可以使用图标热点标签来定义图标图像的哪一部分锚定在您点的纬度/经度上。在这种情况下,我使用了图像的中心,但如果需要,您可以使用箭头的原点或尖端。

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
    <name>arrow icons with headings</name>

    <Placemark>
        <name>heading: 0</name>
        <Style>
            <IconStyle>
                <scale>3</scale>
                <heading>0</heading>
                <Icon>
                    <href>http://maps.google.com/mapfiles/kml/shapes/arrow.png</href>
                </Icon>
                <hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
            </IconStyle>
        </Style>        
        <Point>
            <coordinates>-90,38</coordinates>
        </Point>
    </Placemark>

    <Placemark>
        <name>heading: 75</name>
        <Style>
            <IconStyle>
                <scale>3</scale>
                <heading>75</heading>
                <Icon>
                    <href>http://maps.google.com/mapfiles/kml/shapes/arrow.png</href>
                </Icon>
                <hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
            </IconStyle>
        </Style>
        <Point>
            <coordinates>-85,38</coordinates>
        </Point>
    </Placemark>

    <Placemark>
        <name>heading: 150</name>
        <Style>
            <IconStyle>
                <scale>3</scale>
                <heading>150</heading>
                <Icon>
                    <href>http://maps.google.com/mapfiles/kml/shapes/arrow.png</href>
                </Icon>
                <hotSpot x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
            </IconStyle>
        </Style>
        <Point>
            <coordinates>-80,38</coordinates>
        </Point>
    </Placemark>    

</Document>
</kml>

推荐阅读