Google Maps V3: Loading infowindow content via AJAX

前端 未结 4 1618
轮回少年
轮回少年 2020-12-24 06:47

What is the best way to load content into my infowindow using ajax? Right now I am getting a similar effect using iframes but I am not that that happy with it. I thought thi

4条回答
  •  温柔的废话
    2020-12-24 07:10

    for (var i = 0; i < markersClient.length; i++) {
                var location = new google.maps.LatLng(lats[i], longs[i]);
                var marker = new google.maps.Marker({
                    position: location,
                    map: map,
                    lid: markersClient[i].t
                });
                var infowindow = new google.maps.InfoWindow({
                    content: ""
                });
                //debugger;
                marker.setTitle(" - ");
                markers.push(marker);
                google.maps.event.addListener(marker, 'click', function (target, elem) {
                    infowindow.open(map, marker);
                    $.ajax({
                          success:function () {
                          infowindow.setContent(contentString);
                         }
                   });
    

    intitalize map , marker , infowindow(as no content) and on marker 's click handler make ajax request

提交回复
热议问题