title: Variable becomes undefined inside promise
body: <p>I'm working on an Ionic 3 app wich uses <a href="https://ionicframework.com/docs/native/google-maps/" rel="nofollow noreferrer">Ionic Native Google Maps plugin</a>.
  I'm trying to use <a href="https://github.com/coopernurse/node-pool" rel="nofollow noreferrer">node pool</a> with the Google Maps instance to create a marker pool. </p>
  
  <p>My problem is that inside the new Promise in the createPool function, this.map is undefined, even though it has been created by the loadMap() function. 
  I read <a href="https://stackoverflow.com/questions/36870467/what-is-the-order-of-execution-in-javascript-promises/36877743#36877743">this awesome post</a> about promises but I can't figure out how that applies to my case. I would be very grateful if anyone could help me.</p>
  
  <pre><code>ngAfterViewInit() {
      this.platform.ready()
        .then(_ =&gt; {
          return this.loadMap()
        })
        .then(_ =&gt; {
          this.markerpool = this.createPool();
          this.markerpool.on('factoryCreateError', err =&gt; console.log(err));
        })
  } 
  
  
  createPool() {
      var factory = {
        create: function () {
          return new Promise((resolve, reject) =&gt; {
            this.map.addMarker({
              icon: 'assets/icon/sun.png',
              visible: false
            })
              .then(marker =&gt; {
                // icon anchor set to the center of the icon
                marker.setIconAnchor(42, 37);
                resolve(marker);
              })
          })
        },
        destroy: function (marker: Marker) {
          return new Promise((resolve, reject) =&gt; {
            marker.remove();
            resolve();
          })
        }
      }
      var opts = {
        max: 60, // maximum size of the pool
        min: 20 // minimum size of the pool
      }
      return GenericPool.createPool(factory, opts);
    }
  
  loadMap() {
      this.mapElement = document.getElementById('map');
      let mapOptions: GoogleMapOptions = {
        camera: {
          target: {
            lat: 40.9221968,
            lng: 14.7907662
          },
          zoom: maxzoom,
          tilt: 30
        },
        preferences: {
          zoom: {
            minZoom: minzoom,
            maxZoom: maxzoom
          }
        }
      };
  
      this.map = this.googleMaps.create(this.mapElement, mapOptions);
      this.zoomLevel = this.getZoomLevel(maxzoom);
      return this.map.one(GoogleMapsEvent.MAP_READY);
    }
  </code></pre>