Can';t将单独的geojson文件加载到Mapbox的javascript变量中

Can';t将单独的geojson文件加载到Mapbox的javascript变量中,javascript,mapbox,geojson,Javascript,Mapbox,Geojson,使用Mapbox示例商店定位器,我构建了自己的版本 然而,Mapbox示例在html本身中包含所有geojson数据,这对于我不断增长的数据集来说会变得相当笨拙。相反,我希望能够将geojson数据与html文件分开。所以我把它拉到了“test.geojson”中,并进行了检查以确保它是有效的。我阅读了一些关于如何从单独的本地文件(或url)加载geojson数据的说明,因此: 但正如你在链接上看到的,它不起作用。我在javascript中遗漏了什么 //I replaced the geojs

使用Mapbox示例商店定位器,我构建了自己的版本

然而,Mapbox示例在html本身中包含所有geojson数据,这对于我不断增长的数据集来说会变得相当笨拙。相反,我希望能够将geojson数据与html文件分开。所以我把它拉到了“test.geojson”中,并进行了检查以确保它是有效的。我阅读了一些关于如何从单独的本地文件(或url)加载geojson数据的说明,因此:

但正如你在链接上看到的,它不起作用。我在javascript中遗漏了什么

//I replaced the geojson data that had previously been in the html with this to try and create a variable that loads the geojson data from a separate file
var stores = L.mapbox.featureLayer()
.loadURL('test.geojson')
.addTo(map);

// This was what was in the original code I got from the mapbox example
map.on('load', function (e) {
map.addSource("places", {
  "type": "geojson",
  "data": stores
});
buildLocationList(stores);
});