KMLViewer Apple's example not working

前端 未结 2 1838
南旧
南旧 2021-01-20 15:17

I\'ve been searching for quite sometime an answer to my problem with no success. So here it goes...

KMLViewer, Apple\'s example is not working in some cases. After e

相关标签:
2条回答
  • 2021-01-20 16:00

    Yup. Thanks a lot for your fast response. I've discovered in the morning that the problem is with these tags together (close&open)

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

    My plan:

    Save the output from URL to a NSString, remove if exists the tags above, afterwards save to a file and send it to KMLParser. I'll get back when i'm finished.

    Again thanks a lot for your response.

    0 讨论(0)
  • 2021-01-20 16:11

    It looks like KMLViewer can only handle one LineString object per Placemark.

    For the route you tried, Google is returning two LineString objects in the "Route" Placemark (the last one in the file). KMLViewer only displays the second (last) LineString segment.

    Aside from updating the KMLViewer code to add support for multiple LineString objects per Placemark (which looks like a good exercise), you can try these two workarounds:

    Combine the coordinates from the two LineString objects into one LineString. Change:

    <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>
    

    To this:

    <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>
    

    The above might only make sense for routes (line segments) that are supposed to be continuous.

    Another workaround is to split the "Route" Placemark into multiple placemarks (one for each 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>
    

    One issue with this is that the "description" which contains distance and time info will not match the split routes.

    0 讨论(0)
提交回复
热议问题