简体   繁体   English

如何在angular2中的Google自定义叠加层上使用路由器导航?

[英]How to use router navigate on Google custom overlay in angular2?

I have used the Google custom overlay and created a div. 我已经使用了Google自定义叠加层并创建了一个div。 Now I want to navigate to some other route on overlay click. 现在,我想导航到叠加点击上的其他路线。 Please suggest how can I use the router navigation in Angular2? 请提出如何在Angular2中使用路由器导航的建议?

onAdd() {

    var div = document.createElement('div');
    div.style.position = 'absolute';
    div.setAttribute('class', 'circle-box');
    div.className+=' '+this.pointData_.colour.toLowerCase().trim() + '-style';
    div.innerHTML = this.createTemplate();
    this.div_ = div;
    // Add the element to the "overlayImage" pane.
    var panes = this.getPanes();
    panes.overlayMouseTarget.appendChild(this.div_);

    var me = this;
    google.maps.event.addDomListener(this.div_, 'click', function () {
     // use router navigate
    });

};

I guess the main problem is that you're using function() { ... } instead of `() => {} 我想主要的问题是您使用的是function() { ... }而不是`()=> {}

google.maps.event.addDomListener(this.div_, 'click', () => {
  this.router.navigate(...);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM