AnsweredAssumed Answered

Labels for KML Layers

Question asked by mtfresh on Apr 4, 2017
Latest reply on Apr 4, 2017 by mtfresh

Hi, adding a KMLLayer to the map doesn't seem to display any labels.  (There was a similar question about this, but it is a few years old and never really answered.)  Anyway, since KML layers are converted to feature layers, I thought I could set the labeling info on the constituent feature layers by doing something like this:

 

kmlLayer.on("load"function() {     
    var labelingInfo = [{
        "labelExpressionInfo": {
            "expression""$feature.name"
        },
        "labelPlacement""below-right"
    }];
    var layers = kmlLayer.getLayers();
    for (var i = 0; i < layers.length; i++) {
        if (layer[i] instanceof FeatureLayer) {
            layer[i].setLabelingInfo(labelingInfo);
        }
     }
});

I don't get any errors if I do this, but I also don't get any labels.  Should this work for the feature layers created from a KML layer?  If not, is there a correct way to add labels to KML layers?

 

Thanks,

Mike

Outcomes