2014-12-04 4 views
2

Я работал с картой 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) 

Но я не уверен, что это вообще связано.

ответ

2

После отладки методом исключения я, наконец, нашел источник проблемы. Это было в css, во внешней теме.

Виновником была эта линия:

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

Я удалил его и маркеры вернулись :)

+0

Это уверен, что спас меня головную боль и полтора. То же самое случилось со мной. – Josh

Смежные вопросы