Deat OutSystems Community
I am using the following code to add an eventlistener for GeoJSON layers on a Leaflet map on OS11.
var geojsonLayer = L.geoJSON(states, { onEachFeature: function (feature, layer) { layer.on('mouseover', function () {
layer.bindPopup("Lorem Ipsum").openPopup();
});
layer.on('click', function () {
console.log("Lorem Ipsum")
$actions.FillColor("Lorem Ipsum")
}
}).addTo(" + EncodeJavaScript(LeafletMapName) + ");"
While the actions for the PopUp and the console.log (marked in green) work completely fine, I am getting get an "Uncaught TypeError: $actions.Fillcolor is not a function ..." for my Screen Action "FillColor".
Has anyone an idea why this is happening?
Best regards and thanks in advance
Dimitri
Hi Dimitri,
May I know when is this action with this JS is called (in OnInit or OnRender). Also, please make sure that the JS code is inside a Screen Action that belongs to the same screen as FillColor? If so I guess you can try to call the FillColor action inside a setTimeout to delay the call, some thing like this:
setTimeout(function() {if($actions.FillColor) {$actions.FillColor("Lorem Ipsum");}}, 150);
Hi Nghia Hoang
The JS is called in the OnReady Screen Action on the same Screen as the FillColor action.
The setTimeout also didn't work.
Best regardsDimitri