You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the google-map element loads the API library just after the element is created. This creates issues if a temporary instance is created, which is not going to be attached.
Consider the following case:
/* First, create a temporary instance, for example,to extract a prototype for some analysis purpose */varproto=Object.getPrototypeOf(document.createElement('google-map'));/* Later, another instance of map is created and used normally */varmapElement=document.createElement('google-map');mapElement.apiKey='...';document.body.appendChild(mapElement);
Expected outcome: the API library is loaded once only after the element is attached.
Actual outcome: the API library is loaded multiple times.
Solution idea: postpone loading the API library after the element is attached by wrapping the <google-maps-api> tag with <template is="dom-if" if="isAttached">...</template>
Note that debouncing the API url computation, as proposed in GoogleWebComponents/google-apis#77, is not a complete solution for this issue. For the use case above, it will make the second instance to load the API library with the key provided synchronously after the element creation, while the first instance still loads the API without a key.
The text was updated successfully, but these errors were encountered:
I'm facing a similar problem and trying to understand google-map's current behaviour. Seems to me that I can't use createElement with it at all, even if I'm creating only one element and attaching it to the dom directly.
For example, even this code alone doesn't work with me:
Currently, the google-map element loads the API library just after the element is created. This creates issues if a temporary instance is created, which is not going to be attached.
Consider the following case:
Expected outcome: the API library is loaded once only after the element is attached.
Actual outcome: the API library is loaded multiple times.
Solution idea: postpone loading the API library after the element is attached by wrapping the
<google-maps-api>
tag with<template is="dom-if" if="isAttached">...</template>
Note that debouncing the API url computation, as proposed in GoogleWebComponents/google-apis#77, is not a complete solution for this issue. For the use case above, it will make the second instance to load the API library with the key provided synchronously after the element creation, while the first instance still loads the API without a key.
The text was updated successfully, but these errors were encountered: