Add KML stream to map

835
3
07-09-2014 02:20 AM
maximcouton
New Contributor III

Hi,

I want to add a Kml layer to a map. The data is string under kml format. I fought that the api  allows to add a kml layer by giving it a URL, but I can't found un example adding a kml layer by reading it's content from a stream string.

Use case :

  I have a kml file, I want to parse its content and add it to the map.

Thanks,

Maxim,

0 Kudos
3 Replies
JoeFlannery
Occasional Contributor III

Have you tried the KML to Layer (Conversion) tool?

ArcGIS Help (10.2, 10.2.1, and 10.2.2)

0 Kudos
maximcouton
New Contributor III

Hi,

    I am using the ArcGis API  for JavaScript. I am Parsing  the kml file and get its content as an xml stream.

    The Api allows to add a KML layer using an URL but unfortunalety I can't with an XML stream.

    This is kind of a limitation of the ArcGis API,

require(["esri/map", "esri/layers/KMLLayer"],

             

        function ( Map,KMLLayer ){

       

           var kmladdress =  kmlUrl; // ONLY THE URL ALLOWED HER , XML/KML STRING IS NOT WORKING

           var kmlLayer = new KMLLayer(kmladdress);

           _map.addLayer(kmlLayer);  

       

        }       

   );

   So I  you got any idea of how doing it please notify me,

Thanks,

Maxim

0 Kudos
DonOpgenorth
Esri Contributor

I've moved your post into the  Arcgis API for
Javascript
space. You will get a much better answer here as the GeoNet Help is intended for community
help and feedback. I have also added in a few additional tags. You can see more
on the community structure, and what topics are under each space from the following documents:

GeoNet Community Structure

ArcGIS Discussion Forums Migration Strategy

Thanks!

Don

0 Kudos