简体   繁体   中英

get path from kml geoxml3

I am working with google maps and using geoxml3 to parse my kml string and its showing on Google maps , now I want to get lines info like number of lines in kml string and its location can i get the info of lines drawn by parsed kml string?

html

<div id="map" style="height: 720px"></div>

app.ts

function parseKml() {

    var myParser = new geoXML3.parser({map: map});
    myParser.parseKmlString(kmlString);


  }

you can also get path from kml like this :

var myParser = new geoXML3.parser({
    map: map, //your map
    afterParse: function(doc) { // callback after parse
        for (var i = 0; i < doc[0].placemarks.length; i++) {                
            console.log(doc[0].placemarks[i].LineString[0].coordinates) //for coordinates - doc[0].placemarks[i] get more info
        }
    }
});
myParser.parse('http://googlemaps.github.io/js-v2-samples/ggeoxml/cta.kml');

for example

we can get description related to kml string/file by :

myParser.docs[0].placemarks[0]
myParser.docs[0].placemarks[1]
myParser.docs[0].placemarks[2]

use it accordingly as I have three lines

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM