我正在尝试使用单独的geoJSON文件在Leaflet地图中添加德国公司的虚拟标记,但每次Mozilla都返回一个非格式错误。
我已尝试过本主题中提出的有关MIME错误的解决方案:"not well-formed" error in Firefox when loading JSON file with XMLHttpRequest
https://forum.jquery.com/topic/firefox-error-on-valid-local-json-load-not-well-formed
但没有改变。有很多关于服务器问题的话题,但我还在本地。我没有找到其他人使用传单和geojson解决这个问题。
我也试过HTML链接:
<link rel="points" type= "application/json" href="assets/js/mess/german_company.geojson">
在我的js文件中使用此链接:
//dummy data markers
$.getJSON($('link[rel="points"]').attr("href"), function(data){
var markers = L.geoJson(data, {
onEachFeature: function (feature, layer){
layer.addEventListener("click", function(){
var result = document.getElementById("result");
result.innerHTML = feature.properties.Company + "<br/>Sales: " + feature.properties.Sales + " €<br/>Margin: " + feature.properties.Margin + " €";
});
}}).addTo(map);
使用这种方法,地图会随着标记一起显示,因此它可以正常工作,但我仍然没有这么做&#34;没有很好的形成&#34;错误,我认为这会导致我使用的其他插件出错(leaflet.markercluster工作,但当我缩小时标记仍然出现,标记不能用传单removeLayer函数隐藏)
任何人都有想法解决这个问题&#34;没有良好的形成&#34;错误? 谢谢!