Tengo una clase simple que se carga en un mapa de Google, hace algo de ajax y luego, en esa respuesta, eventualmente colocará algunos marcadores en el mapa, la clase se ve así,
class Map extends BaseComponent { constructor(element) { super(element); this._element = element; this.init(); } init() { this.initialiseLoader(); } initialiseLoader(position = {}) { const loader = new Loader({ apiKey: 'xxxxxxxx', version: 'weekly', libraries: [] }); loader.load() .then((google) => { this.map = new google.maps.Map(document.querySelector('.lta-map'), { zoom:12 }); this.map.setCenter({ lat: Manipulator.getDataAttribute(document.querySelector('.lta-map'), 'latitude'), lng: Manipulator.getDataAttribute(document.querySelector('.lta-map'), 'longitude') }); this.placeMarkers(); return true; }) .catch((error) => { alert(error) }); } async placeMarkers() { const markers = await Request.get(`${this.endpoint}?/latititude=${Manipulator.getDataAttribute(document.querySelector('.lta-map'), 'latitude')}&longitude=${ Manipulator.getDataAttribute(document.querySelector('.lta-map'), 'longitude')}`) .catch(() => { console.log('error'); }); console.log(markers); } } Los mapas se cargan bien, pero cuando llega a la llamada this.placeMarkers() , recibo un mensaje de error que dice que,
this.placeMarkers no es una función
¿Es porque es una función asíncrona?
hacer initialiseLoader (posición = {}) y placeMarkers () funciones de flecha como esta
initialiseLoader = (position = {}) => { yout code here ...} placeMarkers = () => { your code here .. }y tal vez mover placeMarkers dentro de initialiseLoader
Eso es todo lo que puedo pensar