Select to view content in your preferred language

Re: Display of KML file in esri javascript from file object

833
2
01-24-2023 06:17 AM
Vinay_Kumar
New Contributor

Yes, It was ArcGIS SDK for JS. I tried with the KMLLayer Class but it was not working when we create it from the upload file. Creating a URL from the Blob and adding it to the KMLLayer Class. 

const blob = new Blob([fileReader.result], {
                    type: "application/vnd.google-earth.kml+xml"
                });
                const url = URL.createObjectURL(blob);
                console.log(url);
               // window.open(url, '_blank');
                externallayer = new KMLLayer({
                    url: url,
                 
                });
 
It shows invalid KML data. 
0 Kudos
2 Replies
ReneRubalcava
Honored Contributor

The KMLLayer doesn't parse KML via the client, it sends the KML url to a utility service that parses it into features and returns those results, so passing a KML blob won't work. The KML url has to be accessible by the utility service.

Per the documentation. https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-KMLLayer.html


The KMLLayer uses a utility service from ArcGIS.com, therefore your kml/kmz files must be publicly accessible on the internet.

 

Raul_Jimenez
Esri Contributor

Thanks Rene for your help here 😊.

BTW: sorry I tried to move the whole thread to this forum but apparently I did it wrong ^_^''.

Just in case, and for context, this is the original question.

 

0 Kudos