0

Please note this question is about the Aura Component Map not about a collection of key/value pairs. Specifically, I'm getting an error when trying to set the required mapMarkers attribute on an Aura component I am working on.

My component features a table of locations (created by using aura:iteration over a list of salesforce records) that a user can select using checkboxes. After checking one or more locations, they can click a button to map those locations.

When the user clicks the button, the controller iterates over the list of records, and if the record is checked, it creates an object and pushes it to an array. Finally, that array is passed into the component to set the value for mapMarkers on the component.

However, I'm getting an error that says "Uncaught Action failed: c:DisplayPanel$controller$mappanels [t.replace is not a function]". The function in the error message is called "Object.t.escapeHTML" which I do not recognize. I thought that maybe I needed to use JSON.parse() or JSON.stringify() before setting the value but neither worked.

Here is the code:

    mappanels: function(component,event,helper) {
        //turns the currently selected panel units into map markers
        const markers = new Array();
        var panels = component.get("v.unsoldpanels");
        for (var i = 0; i < panels.length; i++) {
            if (panels[i].isChecked == true) {
                var marker = new Object(
                    {
                    location: {
                        Latitude: panels[i].Latitude__c,
                        Longitude: panels[i].Longitude__c
                    },
                    icon: 'standard:prompt',
                    title: panels[i].Plant_Unit_Id__c,
                    description: panels[i].Media_Type_Description__c
                });
                markers.push(marker);                                
                    };
                };
        component.set('v.mapMarkers',markers);
},

After clicking the button, the map markers appear in a list next to the map, but do not appear on the map itself. So trying to set the value of the markers is partially working but I can't figure out what is breaking. When I log the value of the markers array it looks fine to me.

1 Answer 1

0

Sorry, the value of panels[i].Plant_Unit_Id__c was a number, so I had to add toString() to the end of it. That fixed it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .