The Google Maps Javascript API v3 KmlLayer doesn't allow any control over what is displayed.
Display individual layer of a KMZ layer on map using ArcGIS API for JavaScript
-
29-06-2022 - |
Question
Is it possible to display individual layers of a kmz file on my map? I am using the ArcGIS API for javascript. Using this KMZ file from the NWS, I would like to display only Current Day 4 outlook through Current Day 8 outlook (5 folders total). "Current Day 4 outlook" is the name of the folder, and within that folder is a layer called "day_4otlk_20130920_prob"
Currently, those layers don't have any data due to low predictability, but in the future they will. This is the code taken from a sample with the KMZ file replaced. Thank you.
<script>
var map;
require([
"esri/map", "esri/layers/KMLLayer",
"dojo/parser", "dojo/dom-style",
"dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!"
], function(
Map, KMLLayer,
parser, domStyle
) {
map = new Map("map", {
basemap: "topo",
center: [-99, 42.68],
zoom: 4
});
parser.parse();
var kmlUrl = "http://www.spc.noaa.gov/products/outlook/SPC_outlooks.kmz";
var kml = new KMLLayer(kmlUrl);
map.addLayer(kml);
kml.on("load", function() {
domStyle.set("loading", "display", "none");
});
});
</script>
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow