我mapbox标记不显示

问题描述:

我已经工作了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) 

但我不确定它是否相关。

经过排除法调试后,我终于找到了问题的根源。这是在外部主题中的CSS。

罪魁祸首就是这条线:

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

我删除,并标记回来:)

+0

这肯定救了我头疼半。这样的事情我也经历过。 – Josh 2015-06-26 02:56:59