Closed JonasSeegers closed 4 years ago
Note that your api key was in the trace. I removed it, but you should regenerate the key. Do you have a minimal example? The samples in this repository still work: https://googlemaps.github.io/v3-utility-library/packages/markerwithlabel/examples/basic.html
Getting the same error using npm packages @googlemaps/loader and @google/markerwithlabel.
Map is loaded correctly, but after trying inserting MarkerWithLabel getting the same error as @JonasSeegers
Error is easy to reproduce, installed npm packages and built following code with webpack:
import { Loader } from '@googlemaps/loader';
import MarkerWithLabel from '@google/markerwithlabel';
export default (function () {
const el = document.createElement('div');
el.style.height = '400px';
document.body.append(el);
const loader = new Loader({ version: 'weekly' });
loader.load().then(() => {
const opts = {
scrollwheel: false,
zoom: 8,
center: new google.maps.LatLng(0, 0),
mapTypeId: google.maps.MapTypeId.ROADMAP,
fullscreenControl: true
};
const map = new google.maps.Map(el, opts);
const marker = new MarkerWithLabel({
position: new google.maps.LatLng(0, 0),
draggable: true,
raiseOnDrag: true,
map: map,
labelContent: 'testLabel',
labelAnchor: new google.maps.Point(22, 0)
});
});
})();
I'm using MarkerWithLabels in Ionic 5 app and got the same error. Looks like something is wrong with the context when google.maps.Marker.apply(this, arguments) is called.
My first guess is that this has something to do with https://github.com/googlemaps/v3-utility-library/blob/907e1b3c397c881e8a07d8645a76a0c20790e6b1/packages/markerwithlabel/src/markerwithlabel.js#L617-L619 and the call to inherits
.
Probably need to change this pattern to match https://github.com/googlemaps/v3-utility-library/blob/master/packages/markerclustererplus/src/overlay-view-safe.ts#L45
This is also plaguing our application. I tried to do as you recommended @jpoehnelt but to no success. Not sure what's happening here as it only happens sporadically, and doesn't seem to happen when you Disable Cache in the network tab of Chrome
@jpoehnelt do you guys plan to investigate and fix this bug in the nearest future? I really need this feature in my project and eagerly await for the new version with bugfix
Same error here with Ionic5 + @googlemaps/loader, @google/markerclustererplus + @google/markerwithlabel.
Is there any dirty quickfix for this problem? I don't understand @jpoehnelt suggestions. Has MarkerClustererPlus anything to do with it?
Thanks!
@medfx I'm using markerwithlabel lib (https://www.npmjs.com/package/markerwithlabel) for now
@jpoehnelt what does the "needs more info" label actually means in this context? Please specify how and what information you need to proceed. Thank you!
This solved my problem
https://stackoverflow.com/a/53761344/7490702
You have to load the library after google maps
I load google maps via https://github.com/googlemaps/js-api-loader. ONLY after the map has loaded (promise/callback) I start the map init and ONLY after that I use MarkerWithLabel. It works most of the time. But sometimes it doesn't, like exactly when you are giving a presentation. 😄
I have rewritten this package into TypeScript and resolved the issue here.
Check it out at https://github.com/googlemaps/js-markerwithlabel and https://www.npmjs.com/package/@googlemaps/markerwithlabel.
There are some minor differences in API. Docs for it are at https://googlemaps.github.io/js-markerwithlabel/index.html.
I've discovered an issue with MarkerWithLabels. I'm loading the Google Maps API like so:
<script defer async src="https://maps.googleapis.com/maps/api/js?key=MY_API_KEY&callback=initMap">
. WithininitMap
, I try to create aMarkerWithLabel
like so:This leads to the error:
I've already googled the error, but everything I found was related to the maps script not being loaded yet, which is not true for my case.