javascript - 按照传单弹出窗口内的链接
问题描述
我有一张传单地图,上面的标记是使用 geoJSON 获得的。我想将 geoJSON 中的文本添加到弹出窗口并使其成为链接。当您单击该链接时,该链接应转到此链接。但是转换没有发生,并且控制台中的错误: Uncaught ReferenceError: bindPopup is not defined。这是我的代码。
var countiesAll = $.ajax({
url: "{% url 'api_master_around' id=master.id %}",
dataType: "json",
success: console.log("County data successfully loaded countiesAll."),
error: function (xhr) {
alert(xhr.statusText)
}
})
var map = L.map('map', {
center: [51.505, -0.09],
zoom: 14
})
setInterval(function () {
map.invalidateSize();
}, 100);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {
foo: 'bar',
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.geoJSON(countiesAll.responseJSON, {
pointToLayer: function (feature, latlng) {
return L.marker(latlng, {icon: iconBlack})
}
}).bindPopup(function (layer) {
var popup = layer.feature.properties.name
return `<a href = "http://{{ s.myCountry.nameCountry_for_sites_full }}:8000/{{ request.default_lang }}/{{ s.myCity_base }}/{{ z.pk }}"> ${popup} </a> `
}).addTo(map);