javascript - 来自 geoJSON 的 Mapbox 标记未出现在 IE9 中

标签 javascript internet-explorer internet-explorer-9 mapbox geojson

我有一个正在从本地 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/

相关文章:

angularjs - 使用 AngularJS ng-disabled 启用/禁用 kendo ui 下拉列表

Javascript 在 IE9 中不工作

javascript - 如何将每个用户链接到他们在 Firebase 中的数据?

javascript - 时刻格式字符串无法识别

css - Firefox 或 Internet Explorer 中不显示关键帧中的背景图像

javascript - 无法在 IE 上使用 jQuery 停止 YouTube 视频

javascript - IE9 中的无效字符 DOM 异常

javascript - 回调中方法的 Sinon 加密 stub

javascript - this.collection.each 不迭代

c# - 加载 View 状态失败。仅在 IE 中出现错误