A number of the classes in Google Maps API v3 can be extended, specifically google.maps.MVCObject and google.maps.OverlayView.
In some of the examples, they will extend a class in the callback function initMap. My application is more robust than those examples and would prefer not to define a bunch of classes in the callback function.
Is the solution to (A) include Google Maps API before my own script and not include a callback function? Or (B) do I just define everything in the callback function? Or (C) some other approach.
Option A
<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY"></script>
<script src="./assets/js/main.js" type="module"></script>
Option B
<script src="./assets/js/main.js" type="module"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY&callback=initMap"></script>
Where initMap is in main.js and looks something like this:
function initMap() {
class Alpha extends google.maps.MVCObject {}
class Bravo extends google.maps.MVCObject {}
class Charlie extends google.maps.MVCObject {}
// More classes.
class Zulu extends google.maps.MVCObject {}
// Rest of code.
}
Option C
Some other approach.