+ Reply to Thread
Results 1 to 9 of 9

Thread: Loading Dynamic KML from web service

  1. #1
    David Erickson
    Join Date
    Oct 2011
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Default Loading Dynamic KML from web service

    I am attempting to use ArcGIS API for Javascript to view KML from a dynamic REST webservice of a 3rd party app server that I control. To test this I have downloaded the html source for the KMLLayer example and am modifying the kmlUrl variable to hit my service.
    http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm#jssamples/layers_kml.html

    var kmlUrl = 'http://localhost:6040/service/query/etc/1.kml';
    var kml = new esri.layers.KMLLayer(kmlUrl);
    map.addLayer(kml);

    The data does not appear. However, if I download the URL to a static KML file and upload that to a public file webhosting (in this case my public DropBox) and then adjust the code to pull from the static URL hosting location, it works just fine.

    Could the localhost or high number port be causing the problem?
    Could any HTTP response headers mess up the KMLLayer constructor? The webserver is setting the content type to "application/vnd.google-earth.kml+xml", which I believe is correct.

    Thanks in advance for help,
    Dave

  2. #2
    Derek Swingley

    Join Date
    May 2010
    Posts
    1,859
    Points
    892
    Answers Provided
    165


    0

    Default Re: Loading Dynamic KML from web service

    Quote Originally Posted by derickson48 View Post
    Could the localhost <snip> be causing the problem?
    Yes, using localhost is the problem. Your KML file has to be publicly accessible to be used with the JS API. This is documented in the Working with KML Layers topic:
    To add a KML file(.kml or .kmz) to a map, the KML must be available via a publicly accessible URL. Locally hosted or KML files inside a firewall are not supported.
    The reason behind this requirement is that the KMLLayer class relies on a service hosted on ArcGIS.com to convert the actual KML to JSON. You can see this happening with firebug or chrome dev tools...here's the URL that's genereated from the simple KML layer sample:
    Code:
    http://utility.arcgis.com/sharing/kml?url=http://dl.dropbox.com/u/2654618/kml/Wyoming.kml&model=simple&folders=&outSR={"wkid":4326}&callback=dojo.io.script.jsonp_dojoIoScript2._jsonpCallback
    --
    @derekswingley | ArcGIS API for JavaScript Team Member.

    If you're posting a code or html sample, please wrap it in code tags.

  3. #3
    David Erickson
    Join Date
    Oct 2011
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Default Re: Loading Dynamic KML from web service

    Thanks for the quick reply.
    This is going to be deployed behind a firewall, so is there a JSON or XML format I could supply to the Javascript API directly? Making JSON is just as easy for us as KML, we'd just like to make the interaction between the client-side Javascript map and the 3rd party web services to be as simple as possible.

    Otherwise I guess I can do it purely in Javscript like
    http://forums.arcgis.com/threads/416...nts-to-the-map
    , but then I'd have to learn how to get description bubbles, etc working.

    Many thanks again

  4. #4
    Derek Swingley

    Join Date
    May 2010
    Posts
    1,859
    Points
    892
    Answers Provided
    165


    0

    Default Re: Loading Dynamic KML from web service

    Quote Originally Posted by derickson48 View Post
    ...is there a JSON or XML format I could supply to the Javascript API directly?
    Yes, take a look at the feature layer from feature collection sample. That shows how you can create a JSON object and pass it to the FeatureLayer constructor to get a feature layer you can add to your map.
    --
    @derekswingley | ArcGIS API for JavaScript Team Member.

    If you're posting a code or html sample, please wrap it in code tags.

  5. #5
    Timothy Greenwell
    Join Date
    Apr 2011
    Posts
    1
    Points
    0
    Answers Provided
    0


    0

    Default Re: Loading Dynamic KML from web service




    Thanks for the information above. It clears a lot up. Are there any products/extensions put out by ESRI that would allow us to host this ourselves? Our network can never be publicly accessible. Another 2D API handles this adequately but we'd prefer to be ESRI across the board. Plus, the net link capability would be very useful.

    Thanks
    TG

  6. #6
    Derek Swingley

    Join Date
    May 2010
    Posts
    1,859
    Points
    892
    Answers Provided
    165


    0

    Default Re: Loading Dynamic KML from web service

    Quote Originally Posted by greenwellt View Post

    Are there any products/extensions put out by ESRI that would allow us to host this ourselves? Our network can never be publicly accessible. Another 2D API handles this adequately but we'd prefer to be ESRI across the board. Plus, the net link capability would be very useful.
    ArcGIS.com does have subscriptions which is a way to keep your data private: http://help.arcgis.com/en/arcgisonli...000007m000000/ There is also an option to host a copy of ArcGIS Online on your network: http://www.esri.com/software/arcgis/...gis/index.html
    --
    @derekswingley | ArcGIS API for JavaScript Team Member.

    If you're posting a code or html sample, please wrap it in code tags.

  7. #7
    Chris Latko
    Join Date
    Jun 2011
    Posts
    2
    Points
    0
    Answers Provided
    0


    0

    Default Re: Loading Dynamic KML from web service

    So is ArcGIS Online from the ArcGIS Portal the only way to do this? All I need is the kml utility which is located at http://utility.arcgis.com/sharing/kml

    I need to add this functionality to my 9.3.1 Server inside my firewall.

    Any advice?

    Thanks!

    Chris

  8. #8
    Derek Swingley

    Join Date
    May 2010
    Posts
    1,859
    Points
    892
    Answers Provided
    165


    0

    Default Re: Loading Dynamic KML from web service

    Quote Originally Posted by clatko View Post
    So is ArcGIS Online from the ArcGIS Portal the only way to do this? All I need is the kml utility which is located at http://utility.arcgis.com/sharing/kml
    Those are your two options: put your kml on a public server and use the service on arcgis.com or host your own arcgis portal. We don't provide the KML service as something you can host on your intranet.
    --
    @derekswingley | ArcGIS API for JavaScript Team Member.

    If you're posting a code or html sample, please wrap it in code tags.

  9. #9
    steve mclaughlin
    Join Date
    Oct 2012
    Posts
    55
    Points
    0
    Answers Provided
    1


    0

    Default Re: Loading Dynamic KML from web service

    Quote Originally Posted by swingley View Post
    Those are your two options: put your kml on a public server and use the service on arcgis.com or host your own arcgis portal. We don't provide the KML service as something you can host on your intranet.
    What exactly do you mean by 'host you own arcgis portal', I've installed a local arcgis mapserver, is it part of that package?

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts