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");
});
});
-
2From 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.htmlEok– Eok2015年07月20日 20:50:10 +00:00Commented Jul 20, 2015 at 20:50
-
Yeah, I'm not finding much either. I'll keep looking. Thanks for searching too.Cameron Sloan– Cameron Sloan2015年07月20日 20:56:39 +00:00Commented Jul 20, 2015 at 20:56
2 Answers 2
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.
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– Cameron Sloan2015年08月05日 14:29:16 +00:00Commented Aug 5, 2015 at 14:29
-
Perhaps you have not added the necessary library!Samane– Samane2015年08月06日 03:42:28 +00:00Commented Aug 6, 2015 at 3:42
-
What do you mean?Cameron Sloan– Cameron Sloan2015年08月07日 14:59:00 +00:00Commented Aug 7, 2015 at 14:59
-
Do you have added the necessary js files?Samane– Samane2015年08月08日 04:12:13 +00:00Commented Aug 8, 2015 at 4:12
-
This is just a guess! May be correct or incorrect diagnosis with you!Samane– Samane2015年08月08日 04:47:09 +00:00Commented Aug 8, 2015 at 4:47
Explore related questions
See similar questions with these tags.