guys, I am using Google Maps overlay which I import in VueJs as
import CustomMarker from "@/components/maps/CustomMarkerClass";
and inside the CustomMarkerClass.js I have the code inside the Class
function CustomMarker(google, latlng, map, count, status, modems, vueThis) {
this.latlng = new google.maps.LatLng(latlng);
this.setMap(map);
this.vueThis = vueThis;
this.count = count;
this.status = status;
this.modems = modems;
}
CustomMarker.prototype = new google.maps.OverlayView();
......
Vue Router config for the url
......
{
path: "/map",
name: "MapMarkers",
alias: ["/map&zoom*"],
component: MarkersMap,
beforeEnter(to, from, next) {
checkLocalStorage();
next();
}
}
.......
when I call http://localhost/8080/map it works fine but when I build the project and upload it to the server I get the error when I call http://mydomain/map
vue-router.esm.js:1897 ReferenceError: google is not defined at Object.GT+g (CustomMarkerClass.js:16) at c (bootstrap 160a9f95e986b8311f12:54)
I import google maps API script via async call in mounted of MarkersMap and wait for it to initialize to draw custom markers later . A bit strange that it works on localhost but when built causes an error when navigating to direct URL