0
클릭시 infowindow를 추가하고 CartoDB 맵 (following this example 및 the documentation)으로 마우스를 가져 가려고하는데 어려움을 겪고 있습니다.CartoDB : 레이어에 정보 창을 추가 하시겠습니까?
이 내 HTML입니다 :
<div id="map"></div>
<script type="infowindow/html" id="infowindow_template">
<span> custom </span>
<div class="cartodb-popup">
<a href="#close" class="cartodb-popup-close-button close">x</a>
<div class="cartodb-popup-content-wrapper">
<div class="cartodb-popup-content">
<h4>{{content.data.postcode}}</h4>
</div>
</div>
<div class="cartodb-popup-tip-container"></div>
</div>
</script>
그리고 이것은 내 자바 스크립트입니다 :
window.onload = function() {
var options = {
center: [53.2, 0.0],
zoom: 5
};
var map_object = new L.Map('map', options);
var cartocss = '#combined { marker-fill-opacity: 0.9; marker-line-color: #FFF;marker-line-width: 1;marker-line-opacity: 1; marker-placement: point; marker-type: ellipse; marker-width: 10; marker-fill: #FF6600; marker-allow-overlap: true; }';
cartodb.createLayer(map_object, {
user_name: 'myname',
type: 'cartodb',
sublayers: [
{
type: "http",
urlTemplate: "http://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}.png",
subdomains: [ "a", "b", "c" ]
},
{
sql: 'SELECT * FROM combined',
cartocss: cartocss
},
]
})
.addTo(map_object)
.on('done', function(layer) {
var sublayer = layer.getSubLayer(1);
cartodb.vis.Vis.addInfowindow(map_object, sublayer, [ 'postcode'], {
infowindowTemplate: $('#infowindow_template').html(),
templateType: 'mustache'
});
})
.error(function(err) {
console.log("error: " + err);
});
});
이지도에 내 지점을 보여 주지만, 내가 그들을 클릭하면 아무 반응이 없습니다. 콘솔에 오류가 없습니다. 내가 도대체 뭘 잘못하고있는 겁니까?
업데이트 : 이상하게도 첫 번째 레이어를 삭제하고 하위 레이어 선택기를 var sublayer = layer.getSubLayer(0)
으로 변경하면 정보 창이 나타납니다. 하지만 두 레이어가 필요합니다!