我正在使用angular2谷歌地图。我想在mouseenter上打开一个信息窗口,需要关闭标记的mouseleave。 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/es6-shim@0.35.0/es6-shim.min.js"></script>
<script src="https://npmcdn.com/zone.js@0.6.12?main=browser"></script>
<script src="https://npmcdn.com/reflect-metadata@0.1.3"></script>
<script src="https://npmcdn.com/systemjs@0.19.27/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
-->
答案 0 :(得分:2)
我想它应该适合你:
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);
}
另请参阅 Plunkr