Read KML files using ArcGIS API for JavaScript

1888
2
07-15-2013 03:30 AM
SHJang
by
New Contributor II
I need a function that my application reads a user upload KML file and displays on the Esri gray canvas map.
I spotted that there is the KMLLayer class but it works only the KML file is accessible via a public URL.
I think I can save user's file on our server first and then display the KML file later.
But I am wondering there is a way that read the file first (the client side) and then save the file later.

Thanks in advance,

Best,
0 Kudos
2 Replies
JeffJacobson
Occasional Contributor III
I haven't ever used this myself, but Leaflet.FileLayer sounds like it would let you convert from KML to GeoJSON on the client without involving a server.

From there you could use Esri's geojson-utils to convert from GeoJSON to Esri geometries. Graphics from those geometries could then be added to the map.
0 Kudos
SHJang
by
New Contributor II
I haven't ever used this myself, but Leaflet.FileLayer sounds like it would let you convert from KML to GeoJSON on the client without involving a server.

From there you could use Esri's geojson-utils to convert from GeoJSON to Esri geometries. Graphics from those geometries could then be added to the map.


Jeff, thank you very much for your answer. I will investigate your suggestion.
Cheers.
0 Kudos