Select to view content in your preferred language

Set service URL for KML layers?

4405
6
Jump to solution
08-26-2014 03:21 PM
MichaelLacy
Occasional Contributor

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

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
RiyasDeen
Frequent Contributor

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.

View solution in original post

0 Kudos
6 Replies
RiyasDeen
Frequent Contributor

Hi Michael,

Are you looking for something similar to this sample?

KML | ArcGIS API for JavaScript

0 Kudos
MichaelLacy
Occasional Contributor

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

0 Kudos
RiyasDeen
Frequent Contributor

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.

0 Kudos
MichaelLacy
Occasional Contributor

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.

0 Kudos
RiyasDeen
Frequent Contributor

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.

0 Kudos
MichaelLacy
Occasional Contributor

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