Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌地图信息窗口中的jqGrid?_Javascript_Google Maps_Jqgrid - Fatal编程技术网

Javascript 谷歌地图信息窗口中的jqGrid?

Javascript 谷歌地图信息窗口中的jqGrid?,javascript,google-maps,jqgrid,Javascript,Google Maps,Jqgrid,我试图让jqGrid进入谷歌地图的信息窗口,但不知怎么的,我无法让它工作 我有以下代码: function infoClosure(map, marker, val) { return function() { content = []; content.push('<div class="infowin">'); content.push('<table id="list1"></table>');

我试图让jqGrid进入谷歌地图的信息窗口,但不知怎么的,我无法让它工作

我有以下代码:

function infoClosure(map, marker, val) {
    return function() {
        content = [];

        content.push('<div class="infowin">');
        content.push('<table id="list1"></table>');
        content.push('<div id="pager1"></div>');
        content.push('<script type="text/javascript">');
        content.push('jQuery("#list1").jqGrid({');
        content.push('url:"getdata.php?lat=' + val.lat + '&long=' + val.long + '",');
        content.push('datatype: "xml",');
        content.push('colNames:["Project id","Project name"],');
        content.push('colModel:[');
        content.push('{name:"projectID",index:"projectID", width:75}');
        content.push('],');
        content.push('rowNum:10,');
        content.push('autowidth: true,');
        content.push('rowList:[10,20,30],');
        content.push('pager: "#pager1",');
        content.push('sortname: "id",');
        content.push('viewrecords: true,');
        content.push('sortorder: "desc",');
        content.push('caption:"Current projects"');
        content.push('});');
        content.push('jQuery("#list1").jqGrid("navGrid","#pager1",{edit:false,add:false,del:false});');
        content.push('</script>');

        infoWindow.setContent(content.join(''));
        infoWindow.open(map, marker);
    }
}
功能信息关闭(地图、标记、val){
返回函数(){
内容=[];
内容推送(“”);
内容推送(“”);
内容推送(“”);
内容推送(“”);
push('jQuery(#list1”).jqGrid({');
push('url:'getdata.php?lat='+val.lat+'&long='+val.long+',');
push('datatype:'xml',');
push('colNames:[“项目id”,“项目名称”],');
content.push('colModel:[');
push({name:“projectID”,index:“projectID”,width:75});
content.push('],');
内容推送('rowNum:10');
内容推送('autowidth:true');
内容推送('行列表:[10,20,30],');
内容推送('pager:#pager1',');
内容推送('sortname:'id',');
content.push('viewrecords:true',);
内容推送('sortorder:'desc',');
内容推送(标题:“当前项目”);
content.push('});');
push('jQuery('list1').jqGrid('navGrid','pager1',{edit:false,add:false,del:false});');
内容推送(“”);
infoWindow.setContent(content.join(“”));
信息窗口。打开(地图、标记);
}
}
我们正在使用
content.push
将jqGrid的java脚本位传递到信息窗口,但这样的代码使google地图无法显示

你知道怎么做吗

问候,,
Carlos.

我错过了代码的
colModel
中第二列(“项目名称”)的定义。此外,您有
sortname:“id”
,而不是
sortname:“projectID”
。我建议您还包括
gridview:true
选项

下一个问题是
将不会关闭。您使用的HTML片段是


??? 在哪里???
另外,我建议您首先调试网格,而不动态创建代码。我的意思是,您可以创建静态的
创建jqGrid,方法与通常的方法相同。只有在代码生效后,您才能包含一行代码,该代码将移动到
infoWindow
中的
infoWindow.setContent

infoWindow.setContent($("#list1").closest(".infowin")[0]); // move div over grid

嗨,我照你说的做了:1)添加了缺失的2)我在信息窗口外测试了网格代码,3)使用content.push(“”)动态移动工作网格代码;比如:内容推送(“”)。。。。内容推送(“”);但现在我收到了一条大错误消息,比如:');内容推送(“”);内容推送(“”);内容推送(“”);内容推送(“”);infoWindow.setContent(content.join(“”));infoWindow.open(映射、标记);}函数codeAddress(){$(document).ready(函数()..…信息闭包(映射,标记,val));});});});}代码地址();}@QLands:我认为存在误解。我建议不要使用任何字符串数组,也不要使用
infoWindow.setContent(content.join(“”))。如果您有一些静态div(
…这是网格…
),您可以移动与
infoWindow.setContent($(“#list1”).closest(.infowin”)[0]相关的工作网格;信息窗口。打开(地图、标记)取而代之。如果您需要让网格在一段时间内不可见,您可以在div上调用
jQuery.hide()
,并在应该看到网格时在div上调用
jQuery.hide()
。您好,我按照您的指示做了,我让它工作了!。。。还有一件事。。。当我点击地图时,市场会正确地显示网格,但一旦我关闭信息窗口,网格将无法与其他标记一起工作。也许我需要把“infowin”移回原来的位置。。。但是我怎么能做到呢?非常感谢@QLands:不客气!例如,您可以使用一些jQuery方法,如
jQuery.insert
jQuery.append
等,在关闭映射之前再次移动div。在这种情况下,您需要注册一些事件处理程序,这些事件处理程序将在关闭映射之前被调用。或者,您可以重新创建网格。您只需创建新的
..
并使用
jQuery.html
jQuery.insert
将其放置在html页面上,然后调用
jQuery(#list1”).jqGrid({…})
。因此,您不需要创建
部件,只需调用现有代码即可。@QLands:我已经看到,您直到现在还没有使用投票权。你有权投票否决任何问题或答案。你可以每天做30次(参见)。投票很重要,因为它将被搜索引擎使用。所以,如果你找到了一些有用的答案或问题,你应该投赞成票。对于搜索引擎来说,接受答案并不那么重要。您只需单击问题/答案左侧的“向上”箭头即可。因此,如果你想帮助其他人找到有用的信息,你应该使用你的投票权。