大佬教程收集整理的这篇文章主要介绍了jquery – 自动平移映射以在加载来自ajax的内容后适合infoWindow,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
// Initialize the info window var InfoWindow = new google.maps.InfoWindow({ content: 'Display Error: Please Try Again',maxWidth: 400 }); // Lots of code to prep the search filters and Now inside an $.ajax().done(function(html) { $('#ajaxstub div.stubCalc').each(function() { } }) method var newMarker = new google.maps.Marker({ position: latlon,icon: $(this).find('.iconstub').text(),title: $(this).find('.namestub').text(),map: gmap }); // onClick show the InfoWindow google.maps.event.addListener(newMarker,'click',function(E) { InfoWindow.content = $('<div class="projectstub" guid=""></div>').attr('guid',guid).get(0); InfoWindow.open(gmap,newMarker); // loadstub(div,guid,[isToolBox],[callBACk()]) is defined in CalcInfo.js so that it can also be used by the Calculator ToolBox Page loadstub($('div.projectstub[guid="' + guid + '"]').get(),false,function() { InfoWindow.setContent(InfoWindow.content); }); });
并且你可以看到loadstub方法进行初始的ajax调用并为文件上传的ajax调用做准备(因此这个infowindow的内容非常动态)
function loadstub(project,isToolBox,callBACk) { if (typeof(isToolBox) === 'undefined') isToolBox = false; $(project).html('<img src="/Styles/images/ajax-loader.gif"/>'); $.ajax({ url: "/ajax.PHP?ajax=CalcInfo",type: "POST",data: { guid: guid,isToolBox: isToolBox.toString() },cache: false }).done(function(html) { $(project).html($(html).html()); $(project).find('#fileInput').change(function() { // More code here to prepare for ajax upload $.ajax({ url: "/ajax.PHP&ajax=Thumbnail&guid=" + guid,data: formdata }).done(function(html) { if ($(html).find('#ajaxContent .error').length > 0) { var errormessage = 'The Server Returned the Following Error(s):\n'; $(html).find('#ajaxContent .error').each(function() { errormessage += $(this).text() + '\n'; }); errormessage += 'Please Try Again'; alert(errormessagE); } }).fail(function() { alert('There Was an Error ConnecTing to the Server. Please Try Again.'); }).always(function() { loadstub(); }); }); if (typeof callBACk == 'function') { callBACk(); } }).fail(function() { $(project).html('<div style="margin: 75px 0; text-align: center;">There Was an Error ConnecTing to the Server<br/>Please Try Again</div>'); }); }
我能够确定通过使用setContent方法而不是分配InfoWindow.content谷歌地图将适当地调整InfoWindow大小,但它不会平移地图以适应InfoWindow的内容,因为它在使用InfoWindow.open时默认().有谁知道一个体面的解决方案?
如果我需要澄清任何事情,请告诉我.
提前致谢.
以上是大佬教程为你收集整理的jquery – 自动平移映射以在加载来自ajax的内容后适合infoWindow全部内容,希望文章能够帮你解决jquery – 自动平移映射以在加载来自ajax的内容后适合infoWindow所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。