Hi,
I have clients with there own local kml files.
And I wanted to create small web app that they will be able to load or drag\drop KML file into the page and then renderer it into KMLLayer (totally failed... ) any idea?...
then i was trying to use the sample of loading shape file
Add shapefile | ArcGIS API for JavaScript 3.17
It use Generate option of the portal but kml is working in different way
You need to Add item to the portal and its not generate something on memory like CSV\Shape file.
Beside adding item into the portal with some kind of authentication with proxy
Do you have any idea how can i implement it?...
Thanks,
Shahar.
The documentation for KMLLayers clearly states:
"Note: The KMLLayer uses a utility service from ArcGIS.com, therefore your kml/kmz must be publicly accessible on the internet. If your kml/kmz files are behind the firewall you will need to set the
esriConfig.defaults.kmlService
to your own utility service. (Requires Portal for ArcGIS)."
Outside of that, I would think the only way to "import" KML files would be to digest the KML's XML content and create a featureCollection for use with a new featureLayer. Of course, you'd have to code such an importer since I don't think anyone else has made one.
I can use the portal in order to create and get KML Item...
But i will need to upload many kml per day,
And i dont really know if its the right approach doing it
Any ideas?...
Also you can create a geoprocessing service to do it. Upload a KML one or many and convert into graphic on map.
something like this:
import glob, zipfile, arcpy
def kmlToFeatures(kmlFile):
arcpy.AddMessage("kmlToFeatures")
arcpy.KMLToLayer_conversion(kmlFile, arcpy.env.scratchFolder, "outKML1")
return arcpy.env.scratchFolder + "/outKML1.gdb/Placemarks/Polygons"
def ProcessInput():
sourceKMLFile = arcpy.GetParameterAsText(0)
outputFeatureClass = kmlToFeatures(sourceKMLFile)
arcpy.SetParameterAsText(1, outputFeatureClass)
ProcessInput()
I will give it a try, this will be easier then working with the Portal...
Thanks!
Since you're dealing with local KML files, you should really be doing the conversion on the client (in the browser via JavaScript) rather than on another server. A client-side conversion will be a lot faster than sending the KML to another server (arcgis.com or GP service).
There are a number of libraries on NPM that can convert from KML to GeoJSON. From there you can use arcgis-to-geojson-utils to get from GeoJSON to ArcGIS features.
Thank you very much i will give it a try
have a great day!
Hi, I also have clients with there own local kml files.
I tried it several times, but still have issues in uploading file.
If you fix this issue, can you please help me?
My email address is loyalman00715@outlook.com