我的地图框标记没有显示

时间:2014-12-04 12:42:29

标签: javascript mapbox

我一直在使用Mapbox地图一段时间了,我将它初始化为:

L.mapbox.accessToken = "token"; //My token
this.map = L.mapbox.map("elmoMap", "mapid", {
    attributionControl: false,
    infoControl: true,
    maxZoom: 12,
    minZo0m: 5
}).setView(new L.LatLng(64.272275900963, 10.036372782080434), 8);

this.map.on('layeradd', function(e: any) {
    if (e.layer && e.layer.feature && e.layer.feature.properties && e.layer.feature.properties.icon) {
        var marker = e.layer;
        var feature: Models.IFeature = marker.feature;
        var icon = feature.properties.icon;
        marker.setIcon(L.icon(icon));
    }
});

我添加了一个带有图片图标的图层:

var structuresData = {
    type: "Feature",
    geometry: {
        type: "Point",
        coordinates: [10.02, 64.2]
    },
    properties: {
        title: "Buoy",
        mapLayer: "Structures",
        icon: {
            iconUrl: "/img/32_573586.png",
            iconSize: [32, 32], // size of the icon
            iconAnchor: [16, 16], // point of the icon which will correspond to marker's location
            popupAnchor: [0, -16], // point from which the popup should open relative to the iconAnchor
            className: "dot"
        }
    }
}

var structuresLayer = L.geoJson(structuresData);
this.map.addLayer(structuresLayer); 

这曾经起作用,但突然标记和图层停止显示。我进入我的控制台的所有内容都是:

GET http://api.tiles.mapbox.com/mapbox.js/v2.2.0/images/marker-icon.png 404 (Not Found)

但我不确定它是否相关。

1 个答案:

答案 0 :(得分:2)

通过淘汰方法调试后,我终于找到了问题的根源。它是在外部主题的css中。

罪魁祸首是这条线:

img {
  max-width: 100% !important;
}

我删除它并且标记回来了:)