I have a third party javascript file app.js which contains the below snippet
(function ($) {
"use strict";
// json for properties markers on map
var props = [];
// custom infowindow object
var infobox = new InfoBox({
disableAutoPan: false,
maxWidth: 202,
pixelOffset: new google.maps.Size(-101, -285),
zIndex: null,
boxStyle: {
background: "url('images/infobox-bg.png') no-repeat",
opacity: 1,
width: "202px",
height: "245px"
},
closeBoxMargin: "28px 26px 0px 0px",
closeBoxURL: "",
infoBoxClearance: new google.maps.Size(1, 1),
pane: "floatPane",
enableEventPropagation: false
});
// function that adds the markers on map
var addMarkers = function (props, map) {}
})(jQuery)
currently am loading the script using the below steps
loadScript(src) {
const script = document.createElement("script");
script.src = src;
script.async = false;
document.body.appendChild(script);
}
and
this.loadScript('js/app.js');
but now I want away to access the function addMarkers from the reactJS component, it seems window.functionName won't work, so how can I achieve that ?
Note : app.js is being loaded in other components too