2014-10-15 1 views
2

그래서 전단지가 있습니다. 그것은 잘 동작했지만 어떻게 든 더 이상 작동하지 않습니다! 내 JS 코드에 오류가 있으면 누구나 말해 줄 수 있습니까? 하나를 찾을 수 없습니다.전단지지도가 회색으로 만 표시되지 않습니다.

var map = L.map('map').setView([50.93985, 6.94013], 13); 

L.tileLayer('https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png', { 
    maxZoom: 13, 
    attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' + 
     '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' + 
     'Imagery © <a href="http://mapbox.com">Mapbox</a>', 
    id: 'examples.map-i86knfo3' 
}).addTo(map); 


L.marker([52.26887, 10.52677]).addTo(map) 
    .bindPopup("<b>Design and Data GmbH</b><br/>XY</b><br/>Braunschweig").openPopup(); 

L.marker([41.87239, 12.48018]).addTo(map) 
    .bindPopup("<b>Design and Data GmbH</b><br/>XY</b><br/>Rom").openPopup(); 

L.marker([50.93985, 6.94013]).addTo(map) 
    .bindPopup("<b>Design and Data GmbH</b><br/>Hohenzollernring 56</b><br/>51109 Köln").openPopup(); 

map.fitBounds([ 
    [50.93985, 6.94013], 
    [52.26887, 10.52677], 
    [41.87239, 12.48018] 
]); 

var popup = L.popup(); 

function onMapClick(e) { 
    popup 
     .setLatLng(e.latlng) 
     .setContent("You clicked the map at " + e.latlng.toString()) 
     .openOn(map); 
} 

map.on('click', onMapClick); 
+0

나는 그것을 살펴보고 사용했던 코드와 비교했습니다. - 죄송합니다. 코드에 문제가 없습니다. 행운을 빕니다. – David

+0

개발자 도구를 열 때 콘솔에 오류가 있습니까? –

+0

@MarkoLetic 아니요, 오류가 없습니다. – lena

답변

4

tileLayer URL에 문제가 있다고 생각 되오니 전단지가 타일을 가져 오려고 할 때 404 오류가 발생합니다.

'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'을 사용하도록 변경하면지도 타일이 올바르게로드됩니다.

+0

네, 맵 박스에 액세스 토큰이 필요하다고 생각합니다. – bw1024

관련 문제