传单中的标记群集存在问题,但它并不想显示在地图上。
$.getJSON("http://unikabutiker.nu/request.php?f=getAcceptedStores", function (json) {
for (var i = 0; i < json.result.length; i++) {
//markers.addLayer(new L.Marker([json.result[i].lat, json.result[i].lng]));
var title = "<p class='lead hovertext' style='margin-top:5px;margin-bottom:5px;font-family: sans-serif !important;'><a target='_blank' href='http://unikabutiker.nu/butik/"+ json.result[i].uri +"'>" + json.result[i].title + "</a></p><i class='fa fa-map-marker'></i> " + json.result[i].adress, //value searched
small = json.result[i].title+". "+json.result[i].adress+", "+json.result[i].city,
city = json.result[i].city,
loc = [json.result[i].lat, json.result[i].lng], //position found
marker = new L.Marker(new L.latLng([json.result[i].lat, json.result[i].lng]), {
title: small
}); //se property searched
marker.bindPopup(title);
markers.addLayer(marker);
}
});
您可以在jsfiddle
查看完整代码和地图答案 0 :(得分:0)
您的某些代码存在问题 - 它会导致脚本崩溃。 L.control.search
为空。评论该行,或检查null:
if (L.control.search) {
L.control.search({ ...
下一个问题是,您从JSFiddle演示中收到“跨站点脚本”错误。我假设这在您自己的服务器上不会出现问题,因此出于测试目的,我将JSON from the service硬编码复制到演示中。
使用此修复程序,标记似乎正常工作:请参阅here。 (你必须缩小一点才能看到标记。)