Javascript Mapbox.js飞到位置(工作),然后打开右标记弹出窗口(失败)
所以我建立了一个简单的地图:Javascript Mapbox.js飞到位置(工作),然后打开右标记弹出窗口(失败),javascript,markers,Javascript,Markers,所以我建立了一个简单的地图: var map = L.mapbox.map('map', 'mapbox.streets') .setView([52.15, 5.5], 8); var myLayer = L.mapbox.featureLayer().addTo(map); // Add custom popups to each using our custom feature properties myLayer.on('layeradd', function(e) {
var map = L.mapbox.map('map', 'mapbox.streets')
.setView([52.15, 5.5], 8);
var myLayer = L.mapbox.featureLayer().addTo(map);
// Add custom popups to each using our custom feature properties
myLayer.on('layeradd', function(e) {
var marker = e.layer,
feature = marker.feature;
// (stuff happens)
marker.bindPopup(popupContent,{
closeButton: false,
minWidth: 500
});
});
// the following is where it all goes wrong:
// Run easings when links are clicked
var side = document.getElementById('map-ui');
for (var i = 0; i < features.length; i++) { // for all the number of features we have
var a = side.appendChild(document.createElement('a')); // add a 'a' child to the side element
a.onclick = (function(feature, i) { // when you click on it
return function() {
map.setView( [ // centre the map to the appropriate coordinates
feature.geometry.coordinates[1],
feature.geometry.coordinates[0]+0.03 // +0.03 puts it a bit to the left, to make room for the tooltip
],12);
var-map=L.mapbox.map('map','mapbox.streets')
.setView([52.15,5.5],8);
var myLayer=L.mapbox.featureLayer().addTo(map);
//使用我们的自定义功能属性向每个窗口添加自定义弹出窗口
myLayer.on('layeradd',函数(e){
var标记=e.layer,
feature=marker.feature;
//(事情发生了)
marker.bindPopup(popupContent{
closeButton:false,
最小宽度:500
});
});
//以下是所有问题的症结所在:
//单击链接时运行测量
var-side=document.getElementById('map-ui');
对于(var i=0;i
这里是我想打开弹出窗口的地方,但我不确定如何触发正确的标记来打开。对于真实的示例,请访问www.boerenmetwater.nl。以下四个示例不起作用:
//marker()[1].openPopup();
//map.marker[i].openPopup();
//t.openPopup(this);
//marker.openPopup();
}
}
)
(features[i], i);
a.href = '#';
a.title = 'klik om naar ' + features[i].properties.plaats + ' te gaan';
a.innerHTML = '<div class = "menu_plaatsnaam">' + features[i].properties.plaats + '</div>';
a.innerHTML += '<div class = "menu_titel">' + features[i].properties.titel + '</div>';
}
//marker()[1].openPopup();
//map.marker[i].openPopup();
//t、 openPopup(这个);
//marker.openPopup();
}
}
)
(特征[i],i);
a、 href='#';
a、 title='klik om naar'+功能[i].properties.plaats+'te gaan';
a、 innerHTML=''+功能[i].properties.plaats+'';
a、 innerHTML+=''+功能[i].properties.titel+'';
}