我有一个正在从本地 geoJSON 文件加载标记的 map 。这在我测试过的所有浏览器(FF、Chrome、Safari、Opera、IE10、IE11)中都可以正常工作,但在 IE9 中则不行。
我在没有 geoJSON(黄色总线标记)的 map 上添加了一个标记,它在 IE9 中显示得很好。
相关代码如下:
// set up mapbox
var map = new L.mapbox.map('map', '########', {
tileLayer: {
detectRetina: true,
minZoom: 2
},
zoomControl: false
});
// marker without geoJSON
L.marker([-37.9, -77], {
icon: L.mapbox.marker.icon({
'marker-size': 'large',
'marker-symbol': 'bus',
'marker-color': '#fa0'
})
}).addTo(map);
// markers with geoJSON
var geoJsonData = L.mapbox.featureLayer().loadURL('http://nomacorc.cuberishosting.com/wp-content/themes/nomacorc/map-lib/sellers-locations.php').addTo(map);
您可以在以下位置查看工作示例:http://nomacorc.cuberishosting.com/purchase-test/ .
这里是 geoJSON 文件的链接:http://nomacorc.cuberishosting.com/wp-content/themes/nomacorc/map-lib/sellers-locations.php
geoJSON 本身似乎在 http://geojsonlint.com/ 对我进行了验证。
最佳答案
看起来这与 loadURL 函数中调用 JSON 的方式有关。我用 AJAX 拉取 JSON 来修复它,如下所示:
// url to file with geojson data
var url = 'http://nomacorc.cuberishosting.com/wp-content/themes/nomacorc/map-lib/sellers-locations.php';
// load geojson file
$.getJSON(url, function(data) {
var featureMarkers = L.mapbox.featureLayer(data, {sanitizer: function(string) {return string;}});
// The rest of my code here...
});
关于javascript - 来自 geoJSON 的 Mapbox 标记未出现在 IE9 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25810368/