Tutorial

Feature attributes by messages

Mapapps
In this tutorial feature attributes are send with the post message approach.
Zoom to the map and click a red marked object to get the attribute information.
The object will be highlighted.
Check the instructions on the bottom to see a code example.
To use the function as seen above, use the following code.

    // Get the feature attributes:
    window.addEventListener(
        "message",
        (evt) => {
            const functionName = evt.data.functionName
            if(!functionName){
                return;
            }
            switch (functionName){
                case "getFeatureAttribute": {
                    // Your code routine
                    break;
                }
                // reset acknowledgment
                case "resetFeatureAttributeResponse": {
                    const message = evt?.data?.detail?.response || "";
                    console.log(message);
                    break;
                }
                default:{}
            }
        },
        false
    );

    // send Reset request
    const integrationElement = document.getElementById('mapIntegrationElement').contentWindow
    if(integrationElement){
        integrationElement.postMessage({functionName: functionName, detail: detail}, "*")
    }
    postEvent("resetFeatureAttribute", {})