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");
 });
});
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jul 20, 2015 at 20:18
2
  • 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 Commented Jul 20, 2015 at 20:50
  • Yeah, I'm not finding much either. I'll keep looking. Thanks for searching too. Commented Jul 20, 2015 at 20:56

2 Answers 2

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.

answered Aug 26, 2015 at 16:48
-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);
Glen Selle
2551 gold badge3 silver badges11 bronze badges
answered Aug 5, 2015 at 10:03
5
  • Unfortunately this didn't work. Where did you find this section of code from? Commented Aug 5, 2015 at 14:29
  • Perhaps you have not added the necessary library! Commented Aug 6, 2015 at 3:42
  • What do you mean? Commented Aug 7, 2015 at 14:59
  • Do you have added the necessary js files? Commented Aug 8, 2015 at 4:12
  • This is just a guess! May be correct or incorrect diagnosis with you! Commented Aug 8, 2015 at 4:47

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.