How can you set the service URL for KML layers? The default is http://utility.arcgis.com/sharing/kml, but I want to have it use our local Portal for ArcGIS (i.e. https://myserver/arcgis/sharing/kml). The Flex API had a serviceURL property in the KML layer class:
https://developers.arcgis.com/flex/api-reference/com/esri/ags/layers/KMLLayer.html#serviceURL
However, there is no such property in the JavaScript API. I also looked in esri.config and arcgis.utils, but I don't see any corresponding property in those, either.
Thanks,
Mike
Solved! Go to Solution.
Hi Michael,
You will have to override esri.layers.KMLLayer with your own custom class. set your service url for serviceUrl property. your class will look something like below.
var myKmlLayer = declare(esri.layers.KMLLayer,{
serviceUrl: "https://myserver/arcgis/sharing/kml"
});
var kmlLayer = new myKmlLayer();
map.addLayer(kmlLayer)
Reference: Classy JavaScript with dojo/_base/declare - The Dojo Toolkit might help further.
Hi Riyas,
Thanks for the reply. I am loading the KML layer as in the example you cited. However, I want to change the KML service that is used to convert the KML into features. The example is just using the default service, and I haven't found a way to change it.
Mike
Hi Michael,
What happens when you replace http://dl.dropbox.com/u/2654618/kml/Wyoming.kml with your URL?
If your kml is a public url please share.
One thing I noticed is your sample url has https, if it is secured then you should use credential.
The KML URL is irrelevant. I want to change the URL for the KML service that converts the KML into features. When you create a KML layer, the KML URL is passed to the service, which then downloads and parses the KML, converts it into features, and returns a JSON string to the client. By default, it uses the ESRI service at http://utility.arcgis.com/sharing/kml, but I want to know if it's possible to change that and have it use our own. The motivation is that (in theory), our service would be able to handle URLs on our internal servers that the ESRI service cannot access.
Hi Michael,
You will have to override esri.layers.KMLLayer with your own custom class. set your service url for serviceUrl property. your class will look something like below.
var myKmlLayer = declare(esri.layers.KMLLayer,{
serviceUrl: "https://myserver/arcgis/sharing/kml"
});
var kmlLayer = new myKmlLayer();
map.addLayer(kmlLayer)
Reference: Classy JavaScript with dojo/_base/declare - The Dojo Toolkit might help further.
Hi Riyas,
I think that will work. I say "think", because there are some security issues on our server (unrelated to the JavaScript API) that are preventing it from actually downloading the KML. However, looking at it in Fiddler, it *is* accessing the KML service on our server now, instead of the default ESRI service. Thanks for your help!
Mike