2012-09-18 4 views
0

구글지도의 정보창와의 GetResources 다음과 같이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.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> 

그리고 2 개의 GetResources의 내용이 호출됩니다

var marker[[+id]] = new google.maps.Marker({ 
     map: map, 
     position: new google.maps.LatLng([[+branch-latlng]]), 
         title:"[[+pagetitle]]" 
    }); 

newMarkerInit :

google.maps.event.addListener(marker[[+id]], 'click', onMarkerClick); 

하지만 setContent 코드에 배치 된 템플릿 변수는 가져 오지 않습니다. 이는 맵 페이지 헤더에서 한 번만 참조되고 일반적으로 각 문서를 반복해야하기 때문입니다. BranchMapMarkerTpl 내에 새로운 infowindow를 만들려고 시도했지만 작동하지만 마지막으로 infowindow를 닫지 않습니다.

템플릿 변수 값을 가져올 수 있도록 어떻게 다시 팩토링 할 수 있습니까? 사전에

감사합니다.

답변

0

템플릿의 템플릿 변수 구문은 [[*tvname]]입니다. 시도 : 변수 값이 자리에 출력되는 및 템플릿 변수 태그를 통해 구문 분석되지 않은 템플릿으로, 당신의 GetResources 청크 내에서 사용되는

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>'); 

[[+tvname]]하는 것이 올바른 것입니다.

+0

나는 정말 바보 같다. 예, 구문에 대해 절대적으로 맞습니다 - 불행히도 여전히 값을 생성하지는 않습니다. – user1604175

+0

'소스보기'를 할 때 위에 언급 한 TV가 비어 있습니까? 템플릿의 주 게시물에 스크립트 코드가 정확히 어디에 있습니까? 아니면 덩어리? '[[* pagetitle]]'이 나타나지 않는다면 매우 놀랍습니다 – okyanet

+0

출력 수정 자에 대한 문법 오류가 더 심각하다는 것을 알아 채 셨습니다. [[* branch-more : htmlent]]'not ['[ * branch-more.htmlent]]'. 지점 이메일과 동일합니다. – okyanet

관련 문제