错误修复信息窗口

时间:2018-12-17 12:15:12

标签: javascript dictionary infowindow

我有问题需要帮助!

我简单地使用“信息”窗口: InfoWindow old

其功能是:如果单击标记,则显示信息。 我用于此功能的代码是:

  var infowindowsproject = new google.maps.InfoWindow({
                  content: contentat,
                  PROID: projectnearby.PREQDETAILS[0].PROJECTS[q].PROID,
                  position: new google.maps.LatLng(projectnearby.PREQDETAILS[0].PROJECTS[q].LATITUDE, projectnearby.PREQDETAILS[0].PROJECTS[q].LONGITUDE)

              });
              infowindowsprojectnear.push(infowindowsproject);
              markprojectnear.push(markerproject);
          }

          markprojectnear.forEach(function (markernear, index) {
              google.maps.event.addListener(markernear, 'click', function (event) {

                  infowindowsprojectnear.forEach(function (projectnear, index) {
                      if(projectnear.PROID == markernear.PROID) {
                         projectnear.open(map,markernear);
                          design();

                          if(!infowindowselected){
                              infowindowselected = projectnear;
                          }else {
                              if (projectnear.PROID != infowindowselected.PROID) {
                                  cleareinfowindow();
                                  infowindowselected = projectnear;
                              }
                          }


                      }
                  });

              });
          });

现在我设法将信息窗口转换为模式窗口,但是问题是因为在我单击的每个标记中应该是该标记的相关数据,并且此代码是错误的,因为在每个标记中数据都是相同的,因此我使用的代码是: Infowindow with modal

 var infowindowsproject = new google.maps.InfoWindow({
                      PROID: projectnearby.PREQDETAILS[0].PROJECTS[q].PROID,
                      position: new google.maps.LatLng(projectnearby.PREQDETAILS[0].PROJECTS[q].LATITUDE, projectnearby.PREQDETAILS[0].PROJECTS[q].LONGITUDE)

                  });          infowindowsprojectnear.push(infowindowsproject);
                  markprojectnear.push(markerproject);
              }

              markprojectnear.forEach(function (markernear, index) {

             google.maps.event.addListener(markernear, 'click', (function(markernear) {
                return function() {
                /*Bootstrap Modal Pop Up Open Code*/
                $(".modal-title").html(header);
                console.log(PROID);
                $(".modal-body").html(contentat);
                $("#myModal").modal('show');
                }
                    infowindowsprojectnear.forEach(function (projectnear, index) {
                          if(projectnear.PROID == markernear.PROID) {
                             projectnear.open(map,markernear);
                              design();

                              if(!infowindowselected){
                                  infowindowselected = projectnear;
                              }else {
                                  if (projectnear.PROID != infowindowselected.PROID) {
                                      cleareinfowindow();
                                      infowindowselected = projectnear;
                                  }
                              }


                          }
                      });
                })(markernear));
                          });

//请帮助我

0 个答案:

没有答案