【问题标题】:KMLViewer Apple's example not workingKMLViewer Apple 的示例不起作用
【发布时间】:2011-07-05 17:33:54
【问题描述】:

我一直在寻找我的问题的答案,但没有成功。 就这样吧……

KMLViewer,Apple 的示例在某些情况下不起作用。 执行完 README 步骤后,我尝试在葡萄牙里斯本和葡萄牙波尔图之间建立一条路线。最奇怪的事情发生在这里。注释已正确构建,尽管覆盖 (MKPolyline) 没有,但它仅绘制部分路线,并在“注释”中间开始绘制。

我错过了什么? 你可以试试,马德里-巴塞罗那,你也有同样的问题。

在此先感谢您花时间阅读本期。

【问题讨论】:

    标签: ios routes maps mkmapview kml


    【解决方案1】:

    KMLViewer 似乎每个Placemark 只能处理一个LineString 对象。

    对于您尝试的路线,Google 在“路线”地标(文件中的最后一个)中返回两个 LineString 对象。 KMLViewer 仅显示第二个(最后一个)LineString 段。

    除了更新 KMLViewer 代码以添加对每个 Placemark 多个 LineString 对象的支持(这看起来是一个很好的练习)之外,您还可以尝试以下两种解决方法:

    将两个 LineString 对象的坐标组合成一个 LineString。变化:

    <Placemark>
        <name>Route</name>
        <description>some cdata stuff here</description>
        <GeometryCollection>
            <LineString><coordinates>coord1 … coordN</coordinates></LineString>
            <LineString><coordinates>coordN+1 … coordK</coordinates></LineString>
        </GeometryCollection>
        <styleUrl>#roadStyle</styleUrl>
    </Placemark>
    

    到这里:

    <Placemark>
        <name>Route</name>
        <description>some cdata stuff here</description>
        <GeometryCollection>
            <LineString><coordinates>coord1 … coordN coordN+1 … coordK</coordinates></LineString>
        </GeometryCollection>
        <styleUrl>#roadStyle</styleUrl>
    </Placemark>
    

    以上内容可能只对应该是连续的路线(线段)有意义。

    另一种解决方法是将“路线”地标拆分为多个地标(每个 LineString 一个):

    <Placemark>
        <name>Route A</name>
        <description>some cdata stuff here</description>
        <GeometryCollection>
            <LineString><coordinates>coord1 … coordN</coordinates></LineString>
        </GeometryCollection>
        <styleUrl>#roadStyle</styleUrl>
    </Placemark>
    <Placemark>
        <name>Route B</name>
        <description>some cdata stuff here</description>
        <GeometryCollection>
            <LineString><coordinates>coordN+1 … coordK</coordinates></LineString>
        </GeometryCollection>
        <styleUrl>#roadStyle</styleUrl>
    </Placemark>
    

    这样做的一个问题是包含距离和时间信息的“描述”与拆分路线不匹配。

    【讨论】:

      【解决方案2】:

      是的。非常感谢您的快速回复。我早上发现问题在于这些标签在一起(关闭和打开)

      </coordinates></LineString><LineString><coordinates>
      

      我的计划:

      将 URL 的输出保存到 NSString,如果存在上述标签,则删除,然后保存到文件并将其发送到 KMLParser。 完成后我会回来的。

      再次感谢您的回复。

      【讨论】:

      • 我是这样解决的,如果您需要更多帮助来了解我所做的事情,请私信我 :)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-02
      • 2013-01-11
      • 1970-01-01
      • 1970-01-01
      • 2012-07-05
      相关资源
      最近更新 更多