开发者

How to call jquery function for alternate gmaps infowindow?

I want to call jQuery function like modal box instead of using gmaps infowindows.

How can I do that?

Here is the code, it's still using default infowindows:

var marker;

function initialize() {
  if (GBrowserIsCompatible()) {
    var map = new GMap2(document.getElementById("map_canvas"));
    map.setCenter(new GLatLng(37.4419, -122.1419), 13);

    GEvent.addListener(map, "click", function(overlay, latlng) {
          if (latlng) {
        marker = new GMarker(latlng, {draggable:true});
        GEvent.addListener(marker, "click", function() {
          var html = "<table>" +
                     "<tr><td>Name:</td> <td><input type='text' id='name'/> </td> </tr>" +
                     "<tr><td>Address:&开发者_JAVA技巧lt;/td> <td><input type='text' id='address'/></td> </tr>" +
                     "<tr><td>Type:</td> <td><select id='type'>" +
                     "<option value='bar' SELECTED>bar</option>" +
                     "<option value='restaurant'>restaurant</option>" +
                     "</select> </td></tr>" +
                     "<tr><td></td><td><input type='button' value='Save & Close' onclick='saveData()'/></td></tr>" +
                         "";



          marker.openInfoWindow(html);
        });
        map.addOverlay(marker);
      }
    });

  }
}

The infowindows dialog from this code :

   marker.openInfoWindow(html);

Help me, Thanks in advance.


First, you have to create a dialog div like this (anywhere in the page):

<div id="dialog" style="display:none"></div>

Then, Instead of

marker.openInfoWindow(html);

You should do

$("#dialog").html(html);
$("#dialog").dialog();

(You must have included the proper scripts, of course)

More info on jQuery dialog here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜