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
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.
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.
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.
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.
Are you looking for something similar to this sample?
KML | ArcGIS API for JavaScript
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.