I tried using the "layerview-create" to parse for visible points?
I couldn't see them unless I put some long delay.
let layer = new KMLLayer({ url: "http://quickmap.dot.ca.gov/data/lcs.kml" }); layer.on("layerview-create", event => {
let layerView = event.layerView;
layerView.when(()=>{
let allVisiblePoints = layerview.allVisiblePoints;
debugger;
});
})
James,
Does the loaded property not work for you?
It looks like with that service, the KML is defined with Icon images, but I think the URLs are invalid now. I get timeouts for images like https://quickmap.dot.ca.gov/img/lcs-32x32.png. Once the requests timeout, the API falls back to using regular markers for the symbols instead of the image style URLs in the KML. This is why it takes time for the markers to display.
Edit: The non-https URL works, but we make all requests over https now. If that subdomain had https enabled, then everything should work as normal.
The kml file was from the example snippet in KMLLayer documentation.
I don't think it ever worked since 4.10 since that sample kml does not enable https and its cors headers are not available.
About the API fallback, it doesn't work if my site hosted using https. On http, it shows them as black dots.
Try http://developers.google.com/kml/documentation/KML_Samples.kml instead.
Inspecting the layerview.allVisiblePoints
, it is empty unless I look again like 4-5 seconds later via setTimeout
I see now! You need to wait for the LayerView to finish updating.
You can do that like this.
view.whenLayerView(layer).then(function(layerView) {
watchUtils.whenFalseOnce(layerView, "updating").then(function() {
console.log(layerView.allVisiblePoints);
});
});
All the LayerViews have the same behavior. Once they are created they still need to fetch the data so might not be done when you first get it. You can refer to this sample. https://developers.arcgis.com/javascript/latest/sample-code/featurelayerview-query/index.html
Well, that didn't work.
Without using the console.log, the layerview.allVisiblePoint, the collection is still empty
The console.log is almost equivalent to using setTimeout as in chrome debugger, I have to manually expand to see the values
Got a repro now. This might be a bug, I'll get it to the team, thanks!
Thanks