googlemap吧 关注:61贴子:78
  • 4回复贴,共1

Google map infoWindow中添加Button点击为什么不能响应?

只看楼主收藏回复

高级一些的Google map infoWindow如何写?就像百度地图添加地标时那样可以手动添加地标名和描述啊?我要添加一个Button,添加后click却不能触发事件,为什么?高手帮忙啊,急!谢了


1楼2010-09-23 16:38回复
    我没有好办法。
    只能在最外面写个函数(如 function onInfoWindowBtnClicked)用来接收该Button的点击
    而该button的html写成这样:
    <input type="button" onClick="onInfoWindowBtnClicked()" />


    IP属地:河南2楼2010-12-21 16:42
    回复
      自己编写一个WindowInfo
      在其中添加你要添加的按钮,把这个按钮做成表单提交就可以了
      function ShowClickMarker(marker) {
           GEvent.addListener
                   (marker, "click",
                      function (point) {
                          var inputForm = document.createElement("form");
                          if (marker.getTitle()) {
                              inputForm.id = 'marker_' + marker.getTitle();
                          }
                          else {
                              inputForm.id = 'marker_point';
                          }
                          inputForm.setAttribute("action", "#");
                          inputForm.onsubmit = function () {
                              Ext.getCmp('map_google').getMap().closeInfoWindow();
                              storeMarker(this.found.value);
                              return false;
                          };
                          var point = marker.getLatLng();
                          if (point) {
                              // Lat纬度;Lng经度
                              var n = point.lng();
                              var e = point.lat();
      


      3楼2011-01-20 14:40
      回复
                                var Point = new GLatLng(e, n, true);
                                if (marker.getTitle()) {
                                    inputForm.innerHTML =
                       "<fieldset id='field1' style = 'width:300px'>"
                     + "<lengend>" + marker.getTitle() + "信息:</legend>"
                     + "
        "
                     + "<label for = 'left'>经度:</label>"
                     + "<label for = 'left'>" + n + "</label>"
                     + "
        "
                     + "<label for = 'left'>纬度:</label>"
                     + "<label for = 'left'>" + e + "</label>"
                     + "
        "
                     + "
        "
                     + "<a onclick='pathinfro()' href='#'>获取路线</a>"
                     + "&nbsp;&nbsp;"
                     + "<a href='#'>在附近搜索</a>"
                     + "&nbsp;&nbsp;"
                     + "<a onclick='SaveMap()' href='#'>保存到...</a>"
                     + "&nbsp;&nbsp;"
                     + "<a onclick='MarkerSearchBigger()' href='#'>在此处放大</a>"
                     + "
        "
                     + "
        "
                     + "<div id='markerSerch'>"
                     + "<input type ='text' id='found' style ='width:220px'/>"
                     + "<input type ='submit' value = '搜&nbsp;&nbsp;&nbsp;&nbsp索' style ='float:right;'/>"
        


        4楼2011-01-20 14:40
        回复
                       + "</div>"
                                      //+ '<br'
                       + "</fieldset>";
                                  }
                                  else {
                                      inputForm.innerHTML =
                         '<fieldset id="field1" style ="width:300px">'
                       + '<lengend>坐标点信息:</legend>'
                       + '
          '
                       + '<label for = "left">经度:</label>'
                       + '<label for = "left">' + n + '</label>'
                       + '
          '
                       + '<label for = "left">纬度:</label>'
                       + '<label for = "left">' + e + '</label>'
                       + '
          '
                       + '
          '
                       + '<a onclick="pathinfro()" href="#">获取路线</a>'
                       + '&nbsp;&nbsp;'
                       + '<a href="#">在附近搜索</a>'
                       + '&nbsp;&nbsp;'
                       + '<a onclick="SaveMap()" href="#">保存到...</a>'
                       + '&nbsp;&nbsp;'
                       + '<a onclick="MarkerSearchBigger()" href="#">在此处放大</a>'
                       + '
          '
                       + '
          '
                       + '<div id="markerSerch">'
                       + '<input type ="text" id="found" style = "width:220px"/>'
                       + '<input type ="submit" value = "搜&nbsp;&nbsp;&nbsp;&nbsp索" style ="float:right;"/>'
                       + '</div>'
                                      //+ '<br'
                       + '</fieldset>';
                                  }
                                  Ext.getCmp('map_google').getMap().openInfoWindow(Point, inputForm);
                              }
                              else {
                                  Ext.MessageBox.alert("提示", "未获取标记点信息!")
                              }
                          });
          代码可以这么写


          5楼2011-01-20 14:40
          回复