将动态Google地图打开到新的弹出窗口

时间:2015-02-18 03:48:53

标签: javascript jquery html google-maps google-maps-api-3

我正在尝试在点击链接后将动态谷歌地图显示到新的弹出窗口。我怎么可能这样做?我已经在div中显示了地图但我无法在弹出窗口中显示它。

请参阅以下代码

               var latitude = -33.87824;
                  var longitute =151.21084;
                  var latlon = new google.maps.LatLng(latitude,longitute);
                  var mapOptions = {
                      zoom: 13,
                      center:latlon ,
                      mapTypeId: google.maps.MapTypeId.ROADMAP
                  }
                  var mapCanvas = document.getElementById("map-canvas");
                  mapCanvas.style.width = "300px";
                  mapCanvas.style.height = "300px";
                  document.body.appendChild(mapCanvas);
                  var map = new google.maps.Map(mapCanvas, mapOptions);

                  var marker = new google.maps.Marker({
                              position: latlon,
                              map: map
                     });

                }
                google.maps.event.addDomListener(window, 'load', initialize());

                $("#dynamic-btn-map").click(function(){
                    var win = window.open();
                     var maphtml = $("#map-canvas").html();
                     $(win.document.body).html(maphtml);

                });

0 个答案:

没有答案