I'm trying to import a js function from an external .js file using the "module" type but I keep getting the error "ReferenceError: polygonClick is not defined".
Here's my code:
HTML:
<!DOCTYPE html>
<html>
<head>
...
<script src="js/map.js" type="module"></script>
</head>
<body>
...
<script>
function initMap() {
...
$.getJSON( "./DI.json", function( coords ) {
var building = new google.maps.Polygon({...});
building.setMap(map);
building.addListener('click', (event) => polygonClick(event));
});
...
}
</script>
</body>
</html>
JS:
import {MDCDrawer} from './@material/drawer';
export default { polygonClick };
const drawer = MDCDrawer.attachTo(document.querySelector('.mdc-drawer'));
function polygonClick(event) {
console.log(event);
}
Can someone tell me what I'm doing wrong pls?
Thank you in advance!