0

I have been building a web application using ArcGIS JS API v4.0.Beta1. I am having difficulties finding out how to add KML layers to the scene. How do I add the KMLs? I have tried adding a new feature layer with the URL from the host server and I am having no luck.

Example of what I've tried that doesn't work:

var featureLayer = new FeatureLayer({
url: "[insert KML url here]",
mode: FeatureLayer.MODE_SNAPSHOT

Any ideas?

Additionally: Here is my JSFiddle if you wanted to take a look for yourself

Here is my current .js as of 8/5/2015:

var map, view;

require([
  "esri/Map",
  "esri/views/SceneView",
  "esri/layers/KMLLayer",
  "dojo/dom",
  "dojo/on",
  "dojo/domReady!"
  "dojo/parser", 
  "dojo/dom-style",
], 
function (Map, SceneView, KMLLayer, domStyle, parser) {

  //Create map
  map = new Map({
    basemap: "topo"
  });

  //Create SceneView
  view = new SceneView({
    map: map,
    container: "viewDiv",
    camera: {
      position: [-105.581, 41.305, 3000],
      tilt: 45
    }
  });

    parser.parse();

    var kmlURL = 'http://uwyo.maps.arcgis.com/sharing/rest/content/items/457a85b101ba4fb6a159d4ea16c75153/data';
    var kml = new esri.layers.KMLLayer(kmlURL);
    map.addLayer(kml);
      kml.on("load", function() {
      domStyle.set("loading", "display", "none");
      });



});
  • 2
    From my initial browse of the 4.0beta API, the new API does not (yet?) include the 3.x KMLLayer class for use with KML data. The ESRI sample page in case you haven't already found it: developers.arcgis.com/javascript/jssamples/layers_kml.html – Eok Jul 20 '15 at 20:50
  • Yeah, I'm not finding much either. I'll keep looking. Thanks for searching too. – Cameron Sloan Jul 20 '15 at 20:56
3

The 4.0 beta 1 does not support KML. The KMLLayer will be supported in a future beta version.

Beta 1 only supports the modules documented in the API Reference.

-1
+50

Create a KMLLayer and add it to the map.

var kmlURL = 'http://www.lohneswright.com/ctc/kml/actc_wheels.kml';
var kml = new esri.layers.KMLLayer(kmlURL);
map.addLayer(kml);
  • Unfortunately this didn't work. Where did you find this section of code from? – Cameron Sloan Aug 5 '15 at 14:29
  • Perhaps you have not added the necessary library! – Samane Aug 6 '15 at 3:42
  • What do you mean? – Cameron Sloan Aug 7 '15 at 14:59
  • Do you have added the necessary js files? – Samane Aug 8 '15 at 4:12
  • This is just a guess! May be correct or incorrect diagnosis with you! – Samane Aug 8 '15 at 4:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.