<tfoot id='qw8z3'></tfoot>
      <bdo id='qw8z3'></bdo><ul id='qw8z3'></ul>

    1. <small id='qw8z3'></small><noframes id='qw8z3'>

      <legend id='qw8z3'><style id='qw8z3'><dir id='qw8z3'><q id='qw8z3'></q></dir></style></legend>
      <i id='qw8z3'><tr id='qw8z3'><dt id='qw8z3'><q id='qw8z3'><span id='qw8z3'><b id='qw8z3'><form id='qw8z3'><ins id='qw8z3'></ins><ul id='qw8z3'></ul><sub id='qw8z3'></sub></form><legend id='qw8z3'></legend><bdo id='qw8z3'><pre id='qw8z3'><center id='qw8z3'></center></pre></bdo></b><th id='qw8z3'></th></span></q></dt></tr></i><div id='qw8z3'><tfoot id='qw8z3'></tfoot><dl id='qw8z3'><fieldset id='qw8z3'></fieldset></dl></div>
      1. 单击 InfoWindow Typescript Angular2

        时间:2023-09-09
        <tfoot id='arRKk'></tfoot>
            • <bdo id='arRKk'></bdo><ul id='arRKk'></ul>
              <i id='arRKk'><tr id='arRKk'><dt id='arRKk'><q id='arRKk'><span id='arRKk'><b id='arRKk'><form id='arRKk'><ins id='arRKk'></ins><ul id='arRKk'></ul><sub id='arRKk'></sub></form><legend id='arRKk'></legend><bdo id='arRKk'><pre id='arRKk'><center id='arRKk'></center></pre></bdo></b><th id='arRKk'></th></span></q></dt></tr></i><div id='arRKk'><tfoot id='arRKk'></tfoot><dl id='arRKk'><fieldset id='arRKk'></fieldset></dl></div>
                  <legend id='arRKk'><style id='arRKk'><dir id='arRKk'><q id='arRKk'></q></dir></style></legend>
                    <tbody id='arRKk'></tbody>

                  <small id='arRKk'></small><noframes id='arRKk'>

                  本文介绍了单击 InfoWindow Typescript Angular2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我已经搜索了好几个小时,希望你能帮助我:)

                  Hi I have searched since many hours, I hope you can help me :)

                  如果您单击谷歌地图上的信息窗口,我想显示一个页面.(使用 Ionic 2 中的 ModalController)

                  I want to display a Page if you click on an InfoWindow on google Maps. (Using a ModalController from Ionic 2)

                  点击不起作用..

                  var infoWindow = new google.maps.InfoWindow({
                        content: '<h2 (click)="goToProductPage(product)">Click me</h2>'
                      });
                  
                  
                  goToProductPage(product :any){
                      let modal = this.modalCtrl.create(ProductPage, product);
                  
                      modal.present();
                  }
                  

                  遗憾的是,这不起作用,我也尝试使用内容节点,使用 onclick="",使用 javascript 函数..

                  Sadly this doesn't work, I tried also with a content node, with onclick="", with javascript functions..

                  这是另一个未解决的问题.

                  最好的问候,路易斯

                  setProductMarker(product :any, productLocation :any){
                  
                      var contentWindow = "<h2 id='clickableItem'>Click me</h2>" + product.productName + "<img src='" + product.imgUrl + "' width='60' height='60' /> <br/>" + product.date
                  
                      var clickableItem = document.getElementById('clickableItem');
                  
                      clickableItem.addEventListener('click' , () => {
                         this.goToProductPage(product);
                       });
                  
                      var productMarker = new google.maps.Marker({
                        position: new google.maps.LatLng(JSON.parse(productLocation).latitude, JSON.parse(productLocation).longitude),
                        map: this.map,
                        title:"Product"
                      })
                  
                  
                      var infoWindow = new google.maps.InfoWindow({
                        content: contentWindow
                      });
                  
                      infoWindow.addListener('click', () => {
                        alert("yeah");
                        console.log("yeah");
                      });
                  
                  
                    productMarker.addListener('click', event => {
                      infoWindow.open(this.map, productMarker);
                      this.productNow = product;
                      });
                  
                    }
                  

                  推荐答案

                  解决方案

                  感谢丹尼尔库克和

                  var clickableItem = document.getElementById('clickableItem');
                     clickableItem.addEventListener('click' , () => this.goToProductPage())
                  

                  -> 问题是我的 InfoWindow 内容还没有准备好进行 DOM 操作.

                  -> The problem was my InfoWindow content wasn't ready for the DOM manipulation.

                  因此,感谢这个 domready 侦听器-api-infowindow">问题.

                  So, I added a domready listener thanks to this question.

                  google.maps.event.addListener(infoWindow, 'domready', function() {
                     // your code
                  });
                  

                  这里是完整的源代码:

                  setProductMarker(product :any, productLocation :any){
                      var contentWindow = product.productName + "<h2 id='clickableItem'>Click me</h2><img src='" + product.imgUrl + "' width='60' height='60' /> <br/>" + product.date;
                  
                  
                      var productMarker = new google.maps.Marker({
                        position: new google.maps.LatLng(JSON.parse(productLocation).latitude, JSON.parse(productLocation).longitude),
                        map: this.map,
                        title:"Product"
                      })
                  
                  
                      var infoWindow = new google.maps.InfoWindow({
                        content: contentWindow
                      });
                  
                      google.maps.event.addListener(infoWindow, 'domready', () => {
                        //now my elements are ready for dom manipulation
                        var clickableItem = document.getElementById('clickableItem');
                        clickableItem.addEventListener('click', () => {
                          this.goToProductPage(product);
                        });
                      });
                  
                    productMarker.addListener('click', event => {
                      infoWindow.open(this.map, productMarker);
                      this.productNow = product;
                      });
                  
                    }
                  

                  再次感谢丹尼尔的耐心等待!:)

                  Thank you again Daniel for your patience ! :)

                  这篇关于单击 InfoWindow Typescript Angular2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 ionic2 中为 Web 应用程序管理多个滑块? 下一篇:当 Ionic 2 中的值发生变化时检索本地存储值

                  相关文章

                  最新文章

                1. <legend id='LJ4xN'><style id='LJ4xN'><dir id='LJ4xN'><q id='LJ4xN'></q></dir></style></legend>
                    <bdo id='LJ4xN'></bdo><ul id='LJ4xN'></ul>
                2. <small id='LJ4xN'></small><noframes id='LJ4xN'>

                  <tfoot id='LJ4xN'></tfoot>

                      <i id='LJ4xN'><tr id='LJ4xN'><dt id='LJ4xN'><q id='LJ4xN'><span id='LJ4xN'><b id='LJ4xN'><form id='LJ4xN'><ins id='LJ4xN'></ins><ul id='LJ4xN'></ul><sub id='LJ4xN'></sub></form><legend id='LJ4xN'></legend><bdo id='LJ4xN'><pre id='LJ4xN'><center id='LJ4xN'></center></pre></bdo></b><th id='LJ4xN'></th></span></q></dt></tr></i><div id='LJ4xN'><tfoot id='LJ4xN'></tfoot><dl id='LJ4xN'><fieldset id='LJ4xN'></fieldset></dl></div>