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
Google maps MODX getResources与谷歌地图信息窗口_Google Maps_Modx - Fatal编程技术网

Google maps MODX getResources与谷歌地图信息窗口

Google maps MODX getResources与谷歌地图信息窗口,google-maps,modx,Google Maps,Modx,我正在用以下代码填充Google地图: <script type="text/javascript"> google.maps.event.addDomListener(window, 'load', function() { var map = new google.maps.Map(document.getElementById('gmap'), { zoom: 8, center: new google.maps.LatLng(51.

我正在用以下代码填充Google地图:

    <script type="text/javascript">
  google.maps.event.addDomListener(window, 'load', function() {
    var map = new google.maps.Map(document.getElementById('gmap'), {
      zoom: 8,
      center: new google.maps.LatLng(51.414487, -0.207644),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var infoWindow = new google.maps.InfoWindow;

    var onMarkerClick = function() {
      var marker = this;
      var latLng = marker.getPosition();
      infoWindow.setContent('<div class="map-info-window">\
                <h3>WEA [[+pagetitle]]</h3>\
                <p><strong>Branch contact:</strong> [[+branch-latlng]]</p>\
                <p><strong>Telephone no:</strong> [[+branch-phone:htmlent]]</p>\
                <p><strong>Email:</strong> [[+branch-email.htmlent]]</p>\
                [[+branch-more.htmlent]]\
              </div>' );

      infoWindow.open(map, marker);
    };
    google.maps.event.addListener(map, 'click', function() {
      infoWindow.close();
    });

[[getResources? &debug=`0` &showHidden=`1` &parents=`[[*id]]` &depth=`4` &tpl=`newBranchMapMarkerTpl` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &limit=`0` &where=`{"template:=":9}`]]

[[getResources? &debug=`0` &showHidden=`1` &parents=`[[*id]]` &depth=`4` &tpl=`newMarkerInit` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &limit=`0` &where=`{"template:=":9}`]]
  });
</script>
newMarkerInit:

google.maps.event.addListener(marker[[+id]], 'click', onMarkerClick);
但它并没有像setContent代码那样获取模板变量;这是因为它在地图页面标题中只被引用一次,通常需要在每个文档中循环。我尝试在BranchMapMarkerTpl中创建一个新的infowindow,它可以工作,但在打开另一个infowindow时不会关闭最后一个infowindow

如何将其重新分解,以便提取模板变量值


提前感谢。

模板中模板变量的语法是
[[[[*tvname]]]
。尝试:

infoWindow.setContent('<div class="map-info-window">\
    <h3>WEA [[*pagetitle]]</h3>\
    <p><strong>Branch contact:</strong> [[*branch-latlng]]</p>\
    <p><strong>Telephone no:</strong> [[*branch-phone:htmlent]]</p>\
    <p><strong>Email:</strong> [[*branch-email:htmlent]]</p>\
    [[*branch-more:htmlent]]\
</div>' );
infoWindow.setContent('\
WEA[[*页面标题]]\
分行联系人:[[*分行挂靠]]

\ 电话号码:[[*分支电话:htmlent]]

\ 电子邮件:[[*分支机构电子邮件:htmlent]]

\ [*分支更多:htmlent]]\ ' );

[[+tvname]]
在getResources块中使用是正确的,因为模板变量值被输出到占位符,而不是通过模板变量标记进行解析。

我真是个笨蛋。是的,你的语法是绝对正确的-不幸的是,它仍然不能产生值。是不是我上面提到的那些电视在你“查看源代码”时是空白的?脚本代码在模板中的主帖子中的具体位置?还是一大块?如果
[[*pagetitle]]
没有显示,那就非常令人惊讶了。注意到输出修饰符还有一个语法错误,应该是
[[*branch more:htmlent]]
而不是
[[*branch more.htmlent]
。branch-email也是如此。是的,这些电视是空白的——这有点道理,因为MODX的工作方式,但是我从Google Maps的一个示例中选取了这个示例,并尝试对其进行修改。主脚本位于地图页面的头部,第二个2显然是getResources的块。我以前将占位符作为getResources块的一部分,它们显示正确,但infowindows没有按照上面的说明运行。我同意[[*branch more.htmlent]],但出于某种原因使用冒号会破坏地图。
infoWindow.setContent('<div class="map-info-window">\
    <h3>WEA [[*pagetitle]]</h3>\
    <p><strong>Branch contact:</strong> [[*branch-latlng]]</p>\
    <p><strong>Telephone no:</strong> [[*branch-phone:htmlent]]</p>\
    <p><strong>Email:</strong> [[*branch-email:htmlent]]</p>\
    [[*branch-more:htmlent]]\
</div>' );