title: Google maps listener not properly working in angular2+typescript
body: <p>I wrote a small website with html+js+jquery and used the Google maps api v3. On the map you can draw a polyline, which is possible due to event handlers on the map, e.g.</p>
  
  <pre><code> map.addListener('click', addLatLng);
  </code></pre>
  
  <p>and </p>
  
  <pre><code>function addLatLng(event) {
      // Add a new marker at the new plotted point on the polyline.
      polyline.getPath().push(event.latLng);
  
      var marker = new google.maps.Marker({
          position: event.latLng,
          draggable: true,
          map: map,
          icon: {
            path: google.maps.SymbolPath.CIRCLE,
            scale: 5
          }
      })
  
      var i = gmarkers.length;
      marker.addListener('drag', function() {
        polyline.getPath().setAt(i, marker.getPosition());
      });
   ...
  }
  </code></pre>
  
  <p>Now I want to translate this page into an angular2 component. I know that the eventhandling should maybe not be done in that way, but I don't know how to do it otherwise...</p>
  
  <p>I can change the first line to </p>
  
  <pre><code>this.map.addListener('click', (event) =&gt; this.addLatLng(event));
  </code></pre>
  
  <p>and this will work as intended. BUT (!)</p>
  
  <pre><code>addLatLng(event) {
      // Add a new marker at the new plotted point on the polyline.
      this.polyline.getPath().push(event.latLng);
  
      var marker = new google.maps.Marker({
          position: event.latLng,
          draggable: true,
          map: this.map,
          icon: {
            path: google.maps.SymbolPath.CIRCLE,
            scale: 5
          }
      })
  
  
      var i = this.gmarkers.length;
  
      marker.addListener('drag', () =&gt; function() {
       // this.polyline.getPath().setAt(i, marker.getPosition());
        console.log("drag listening");
  
      });
    ...
  }
  </code></pre>
  
  <p>won't work. I don't get why the eventlistener can be added to the map but not to the marker on that map. Is it because the new listener is added within the eventhandling of another element? But if so, why was it working in pure Javascript?</p>