Feature info on selection

The most common thing somebody expects when clicking on a feature on a map is to find out stuff about it. Here's a short example of how you can get that with the GIS Cloud JS API.

We'll use the default select tool combined with the viewer's selectionChange event to get the feature id. Then, through the giscloud.features object, we'll get the data and display it in a table.

Property Value

The code:

// bind a handler for the selectionChange event
viewer.selectionChange(function (evt) {
    if (evt.action === "add") {
        // get feature data
        giscloud.features.byId(evt.feature.layerId, evt.feature.featureId)
           .done(displayFeatureData);
    }
});