Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web Map Change Event? #49

Open
pmacMaps opened this issue Oct 9, 2019 · 0 comments
Open

Web Map Change Event? #49

pmacMaps opened this issue Oct 9, 2019 · 0 comments

Comments

@pmacMaps
Copy link

pmacMaps commented Oct 9, 2019

I am working on developing a JavaScript solution to add the alt attribute to images in map popups. Using the events listed in this repo's readme, I cannot get consistent results when changing between webmaps. I have tried the code in different topic.subscribe sections within the custom-scripts.js file.

Is there an event that fires when the webmaps change? I'll provide my sample code below. Any help is greatly appreciated:

let webmap = app.map;

webmap.on('click', function() {

        // only execute code if a popup is displayed on click
        if (webmap.infoWindow.isShowing) {
            
            // img elements within the feature popup
            let popupImage = document.querySelectorAll('div.image > img')[0];

            if (typeof popupImage !== 'undefined') {  
               // popup title - bridge name
               let bridgeNameElement = document.querySelectorAll('div.esriViewPopup > div.mainSection > div.header')[0].innerHTML;
            
                // add alt attribute using bridge's name
               popupImage.setAttribute('alt', bridgeNameElement);// || 'some string'
           }          
        
       }

});    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant