Как показать файл .KML в представлении карты в Android - PullRequest
0 голосов
/ 01 октября 2018

Любой, пожалуйста, помогите мне не показывать файл kml на карте. Я пытаюсь с показанными https://developers.google.com/maps/documentation/android-sdk/utility/kml#demo-app данными kml полигонального типа, но другие данные файла kml типа не работают, пожалуйста, помогите мне, как показать файл kml другого типа на карте,Вот файл .KML.Извините за плохой английский

   <?xml version='1.0' encoding='UTF-8'?>
<kml xmlns='http://www.opengis.net/kml/2.2'>
    <Document>
        <name>MAHA_AHERI_COMP19.xls</name>
        <Placemark>
            <name>1.0</name>
            <description><![CDATA[Latitude: 19.58888889<br>Longitude: 80.14527778]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.58888889</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.14527778</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.14527778,19.58888889,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>2.0</name>
            <description><![CDATA[Latitude: 19.33388889<br>Longitude: 80.16]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.33388889</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.16</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.16,19.33388889,0.0</coordinates>
            </Point>
        </Placemark>`enter code here`
        <Placemark>
            <name>3.0</name>
            <description><![CDATA[Latitude: 19.33888889<br>Longitude: 80.17194444]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.33888889</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.17194444</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.17194444,19.33888889,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>4.0</name>
            <description><![CDATA[Latitude: 19.34055556<br>Longitude: 80.18055556]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.34055556</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.18055556</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.18055556,19.34055556,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>5.0</name>
            <description><![CDATA[Latitude: 19.34916667<br>Longitude: 80.20333333]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.34916667</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.20333333</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.20333333,19.34916667,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>6.0</name>
            <description><![CDATA[Latitude: 19.59111111<br>Longitude: 80.20555556]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.59111111</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.20555556</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.20555556,19.59111111,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>7.0</name>
            <description><![CDATA[Latitude: 19.58555556<br>Longitude: 80.20527778]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.58555556</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.20527778</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.20527778,19.58555556,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>8.0</name>
            <description><![CDATA[Latitude: 19.58138889<br>Longitude: 80.20666667]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.58138889</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.20666667</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.20666667,19.58138889,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>9.0</name>
            <description><![CDATA[Latitude: 19.57277778<br>Longitude: 80.20638889]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.57277778</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.20638889</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.20638889,19.57277778,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>10.0</name>
            <description><![CDATA[Latitude: 19.56555556<br>Longitude: 80.20722222]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.56555556</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.20722222</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.20722222,19.56555556,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>11.0</name>
            <description><![CDATA[Latitude: 19.56083333<br>Longitude: 80.20694444]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.56083333</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.20694444</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.20694444,19.56083333,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>12.0</name>
            <description><![CDATA[Latitude: 19.525<br>Longitude: 80.20888889]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.525</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.20888889</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.20888889,19.525,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>13.0</name>
            <description><![CDATA[Latitude: 19.51555556<br>Longitude: 80.21055556]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.51555556</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.21055556</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.21055556,19.51555556,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>14.0</name>
            <description><![CDATA[Latitude: 19.49916667<br>Longitude: 80.21111111]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.49916667</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.21111111</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.21111111,19.49916667,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>15.0</name>
            <description><![CDATA[Latitude: 19.58<br>Longitude: 80.19777778]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.58</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.19777778</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.19777778,19.58,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>16.0</name>
            <description><![CDATA[Latitude: 19.49388889<br>Longitude: 80.18194444]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.49388889</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.18194444</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.18194444,19.49388889,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>17.0</name>
            <description><![CDATA[Latitude: 19.49166667<br>Longitude: 80.16833333]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.49166667</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.16833333</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.16833333,19.49166667,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>18.0</name>
            <description><![CDATA[Latitude: 19.49111111<br>Longitude: 80.16055556]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.49111111</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.16055556</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.16055556,19.49111111,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>19.0</name>
            <description><![CDATA[Latitude: 19.49138889<br>Longitude: 80.14888889]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.49138889</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.14888889</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.14888889,19.49138889,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>20.0</name>
            <description><![CDATA[Latitude: 19.49472222<br>Longitude: 80.14916667]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.49472222</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.14916667</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.14916667,19.49472222,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>21.0</name>
            <description><![CDATA[Latitude: 19.59<br>Longitude: 80.14694444]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.59</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.14694444</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.14694444,19.59,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>22.0</name>
            <description><![CDATA[Latitude: 19.515<br>Longitude: 80.14583333]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.515</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.14583333</value>
                </Data>
            </ExtendedData>
            <Point>
                <coordinates>80.14583333,19.515,0.0</coordinates>
            </Point>
        </Placemark>
        <Placemark>
            <name>23.0</name>
            <description><![CDATA[Latitude: 19.52694444<br>Longitude: 80.14333333]]></description>
            <styleUrl>#icon-1739-0288D1</styleUrl>
            <ExtendedData>
                <Data name='Latitude'>
                    <value>19.52694444</value>
                </Data>
                <Data name='Longitude'>
                    <value>80.14333333</value>
                </Data>
            </ExtendedData>
            <Point>**strong text**
                <coordinates>80.14333333,19.52694444,0.0</coordinates>
            </Point>
        </Placemark>
        <Style id='icon-1739-0288D1'>
            <IconStyle>
                <color>ffD18802</color>
                <scale>1.0</scale>
                <Icon>
                    <href>http://www.gstatic.com/mapspro/images/stock/503-wht-blank_maps.png</href>
                </Icon>
            </IconStyle>
        </Style>
    </Document>
</kml>  

1 Ответ

0 голосов
/ 01 октября 2018

Что-то похожее на это сработало у меня ..

try {
        String file = Environment.getExternalStorageDirectory().getPath() + "/kmlfile.kml";
        String[] kmlfile = file.split("/");
        String kml=kmlfile[4];

            File myFile = new File(Environment.getExternalStorageDirectory().toString() + "/DCIM/Camera/campus");

           FileInputStream fIn = new FileInputStream(myFile);

         KmlLayer kmlLayer = new KmlLayer(mMap, fIn, getApplicationContext());

        KmlLayer kmlLayer = new KmlLayer(mMap, R.raw.campus, getApplicationContext());

        kmlLayer.addLayerToMap();
        moveCameraToKml(kmlLayer);
    } catch (IOException | XmlPullParserException  e) {
        e.printStackTrace();
    } 
}
...