Sudheer KB
Sudheer KB

Reputation: 1606

angular2 google map marker mouse enter and leave event

I am using angular2 google map.I want to open a Info window on mouseenter and need to close on mouseleave of marker. http://embed.plnkr.co/YX7W20/

<!DOCTYPE html>
<html>
  <head>
    <title>Angular 2 QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- 1. Load libraries -->
     <!-- Polyfill(s) for older browsers -->
    <script src="https://npmcdn.com/[email protected]/es6-shim.min.js"></script>
    <script src="https://npmcdn.com/[email protected]?main=browser"></script>
    <script src="https://npmcdn.com/[email protected]"></script>
    <script src="https://npmcdn.com/[email protected]/dist/system.src.js"></script>
    
    <!-- 2. Configure SystemJS -->
    <script src="systemjs.config.js"></script>
    <script>
      System.import('app').catch(function(err){ console.error(err); });
    </script>
  </head>

  <!-- 3. Display the application -->
  <body>
    <my-app>Loading...</my-app>
    
  </body>
  
</html>


<!-- 
Copyright 2016 Google Inc. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at http://angular.io/license
-->

Upvotes: 0

Views: 754

Answers (1)

yurzui
yurzui

Reputation: 214175

I guess it should work for you:

const baseAddEventListeners = (<any>SebmGoogleMapMarker.prototype)._addEventListeners;
(<any>SebmGoogleMapMarker.prototype)._addEventListeners = function() {
   this._markerManager.createEventObservable('mouseover', this)
    .subscribe(() => { this._infoWindow.open();  });
   this._markerManager.createEventObservable('mouseout', this)
    .subscribe(() => { this._infoWindow.close(); });

  baseAddEventListeners.call(this);
}

See also Plunkr

Upvotes: 2

Related Questions