我正在为圣经营制作游戏,并且想使用 Leaflet.js 制作 map 。我正在使用 Mapbox 创建样式。我通过 csv 上传将罗马和耶路撒冷的坐标导入到 Mapbox 中,它们在 preview 中渲染得很好。 。但是,通过 Leaflet 加载时它们不会显示。请参阅下面的代码:
<head>
<title>Race to Rome</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
</head>
<body>
<div id="mapid" style="height:500px;"></div>
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<h1>Race to Rome</h1>
</body>
<script>
var mymap = L.map('mapid').setView(L.latLng(34,30), 5);
L.tileLayer('https://api.mapbox.com/styles/v1/wheelerj/cioerd0vf001yacm7rff4tj5h/tiles/{z}/{x}/{y}?access_token=pk.eyJ1Ijoid2hlZWxlcmoiLCJhIjoiY2lvZXJheTZrMDByNXVsbTNpZXp0c2VnbCJ9.T_jRdbo0CKUgZ2aiuA3kKA', {
maxZoom: 18,
attribution:
'Imagery ©<a href="http://mapbox.com">Mapbox</a>',
id: 'mapbox.streets'
}).addTo(mymap);
</script>
我需要做什么才能将这些标签包含在传单中?
最佳答案
您可能想考虑使用 Mapbox.js (这是为其用户增强的 Leaflet 分支),并使用其预先构建的功能来处理像这样的功能层。 请参阅下面的示例。
https://www.mapbox.com/mapbox.js/example/v1.0.0/show-marker-as-label/
L.mapbox.featureLayer('MY_FEATURE_LABEL_SET')
.on('ready', function(e) {
gj.addData(this.getGeoJSON());
});
关于javascript - 自定义 Mapbox 切片集未显示在 Leaflet.js 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37334563/