Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mapbox GL JS外部geojson数据不会加载,但是将geojson数据复制到html代码中是可行的_Mapbox_Mapbox Gl Js - Fatal编程技术网

Mapbox GL JS外部geojson数据不会加载,但是将geojson数据复制到html代码中是可行的

Mapbox GL JS外部geojson数据不会加载,但是将geojson数据复制到html代码中是可行的,mapbox,mapbox-gl-js,Mapbox,Mapbox Gl Js,在mapbox GL JS map.addSource上,将数据指向与html文件位于同一目录中的外部geojson文件时,数据不会显示。但是,当我将geojson数据直接复制到html文件中时,它确实出现了。我不认为我的路径是错误的。geojson和heatmap.html在同一个文件夹中,我使用的是Ubuntu 18.04。我希望将geojson数据保存在外部 我正在努力学习本教程: 这不起作用: map.on'load',函数{ map.addSource“树”{ 键入:“geojson

在mapbox GL JS map.addSource上,将数据指向与html文件位于同一目录中的外部geojson文件时,数据不会显示。但是,当我将geojson数据直接复制到html文件中时,它确实出现了。我不认为我的路径是错误的。geojson和heatmap.html在同一个文件夹中,我使用的是Ubuntu 18.04。我希望将geojson数据保存在外部

我正在努力学习本教程:

这不起作用:

map.on'load',函数{ map.addSource“树”{ 键入:“geojson”, 数据:'./trees.geojson' }; 这项工作:

map.on'load',函数{ map.addSource“树”{ 键入:“geojson”, 数据:{type:FeatureCollection,features:[{type:Feature,properties:{dbh:0},几何:{type:Point,坐标:[-79.91746,40.44356]},{type:Feature,properties:{dbh:12},几何:{type:Point,坐标:[-79.94606,40.44961]},{type:Feature dbh:6},几何:{type:Point,坐标:{-79.96474,40.46283]},属性:{dbh:2},几何:{type:Point,坐标:[-80.00949,40.42532]},{type:Feature,properties:{dbh:12},几何:{type:Point,坐标:[-79.93531,40.42282]},{type:Feature,properties:{dbh:12},几何:{type:Point,坐标:[-79.91199,40.37286]},{type:Feature dbh:10},几何:{type:Point 244.434]},{type:Feature,properties:{dbh:-1},geometry:{type:Point,座标:[-79.92158,40.43892]},{type:Feature,properties:{dbh:17},geometry:{type:Point,座标:[-79.97294,40.40908]},{type:Feature properties:{dbh:13},geometry:{type:Point,座标:[-79.97291,40.42896]},{type:Feature dbh:9},座标:[-80.05708,40.45932]},{type:Feature,properties:{dbh:10},geometry:{type:Point,座标:[-79.91069,40.37747]},{type:Feature,properties:{dbh:4},geometry:{type:Point,座标:[-79.98257,40.43154]},{type:Feature dbh:5},geometry:{type:Point,座标:[-79.99177 40.42093},座标:[-type:Point dbh:{类型:点,坐标:[-80.02488,40.41999]},{类型:特征,属性:{dbh:1},几何:{类型:点,坐标:[-79.99531,40.41504]},{类型:特征,属性:{dbh:8},几何:{类型:点,坐标:[-80.0148,40.43467]},{类型:特征,属性:{dbh:6},几何:{类型:点,坐标:[-80.029,40.416]},特征:{dbh:1},几何:{type:Point,坐标:[-80.01647,40.40107]},{type:Feature,properties:{dbh:0},几何:{type:Point,坐标:[-80.02872,40.39468]},{type:Feature,properties:{dbh:16},几何:{type:Point,坐标:[-80.00902,40.38418]},{type:Feature,properties:{dbh:22},几何:{type:Point,坐标:[-80.05166,4340},{type:Feature,properties:{dbh:7},geometry:{type:Point,座标:[-80.0468,40.43461]},{type:Feature,properties:{dbh:11},geometry:{type:Point,座标:[-80.03639,40.44505]},{type:Feature,座标:[-80.03393,40.43546]},geometry:{type:Point[-80.05113,40.43404]},{type:Feature,properties:{dbh:2},geometry:{type:Point,坐标:[-79.93404,40.47953]},{type:Feature,properties:{dbh:-1},geometry:{type:Point,坐标:[-79.88148,40.45954]},{type:Feature dbh:10},geometry:{type:Point,坐标:[-79.9201,40.47591]},geometry:{type:dbh:{类型:点,坐标:[79.92554,40.46622]},{类型:特征,属性:{dbh:10},几何:{类型:点,坐标:[79.94818,40.4595]},{类型:特征,属性:{dbh:28},几何:{类型:点,坐标:[-79.93549,40.48189]},{类型:特征,属性:{dbh:23},几何:{类型:点,坐标:[-79.898,40.888,40},属性:{dbh:29},{,几何:{类型:点,坐标:[-79.94479,40.40905]},{类型:特征,属性:{dbh:-1},几何:{类型:点,坐标:[-80.01717,40.46426]},{类型:特征,属性:{dbh:9},几何:{类型:点,坐标:[-80.02638,40.46093]},{类型:特征,属性:{dbh:22},几何:{类型:点,坐标:{79.93369},{type:Feature,properties:{dbh:11},geometry:{type:Point,座标:[-79.92366,40.42568]},{type:Feature,properties:{dbh:2},geometry:{type:Point,座标:[-79.9568,40.44844]},几何:{type:Feature,座标:[-79.9489,40.45985]},几何:{type:Feature dbh:2},座标:{type:Point[-79.91629,40.4733]},{type:Feature,properties:{dbh:19},geometry:{type:Point,座标:[-79.90083,40.42244]},{type:Feature,properties:{dbh:2},geometry:{type:Point,座标:[-79.96904,40.44207]},{type:Feature dbh:3},geometry:{type:Point,座标:[-80.00736,40.4574]},geometry:12}{类型:点,坐标:[-79.93248,40.46246]},{类型:特征,属性:{dbh:9},几何:{类型:点,坐标:[-79.93568,40.48163]},{类型:特征,属性:{dbh:15},几何:{类型:点,坐标:[ -79.92572,40.46593]},{type:Feature,properties:{dbh:-1},geometry:{type:Point,座标:[-79.93204,40.46653]},{type:Feature,properties:{dbh:10},geometry:{type:Point,座标:[-79.88447,40.45094]},{type:Feature dbh:19},geometry:{type:Point,座标:[-79.92534,40.42169 type:Point,座标:[-79.92534,40.42169,},geometry:{dbh:36}{类型:点,坐标:[79.90062,40.42502]},{类型:特征,属性:{dbh:10},几何:{类型:点,坐标:[-79.94987,40.4215]},{类型:特征,属性:{dbh:8},几何:{类型:点,坐标:[-79.94745,40.4583]},{类型:特征,属性:{dbh:5},几何:{类型:点,坐标:[-79.94746,40.448]},属性:{dbh:11},几何:{type:Point,坐标:[-79.94136,40.40568]},{type:Feature,properties:{dbh:3},几何:{type:Point,坐标:[-79.98904,40.46744]},{type:Feature,properties:{dbh:9},几何:{type:Point,坐标:[-80.01252,40.45821]},{type:Feature dbh:15},几何:{type:Point,坐标:[-79.89635]},{type:Feature,properties:{dbh:32},geometry:{type:Point,座标:[-79.94086,40.4806]},{type:Feature,properties:{dbh:20},geometry:{type:Point,座标:[-79.92815,40.44201]},{type:Feature,座标:[-79.91607,40.42572]},geometry:{type:Feature dbh:11},座标:{type:Point[-79.94567,40.40739]},{type:Feature,properties:{dbh:10},geometry:{type:Point,坐标:[-79.92082,40.45771]},{type:Feature,properties:{dbh:-1},geometry:{type:Point,坐标:[-80.02301,40.45373]},{type:Feature dbh:26},geometry:{type:Point,坐标:[-79.90841,40.4471]},geometry:type:Point{类型:点,坐标:[79.93042,40.45842]},{类型:特征,属性:{dbh:4},几何:{类型:点,坐标:[79.9858,40.44431]},{类型:特征,属性:{dbh:7},几何:{类型:点,坐标:[-80.01556,40.48392]},{类型:特征,属性:{dbh:19},几何:{类型:点,坐标:[-79.929,40},属性:{dbh:18},几何:{类型:点,坐标:[-79.90916,40.43699]},{类型:特征,属性:{dbh:18},几何:{类型:点,坐标:[-79.93322,40.43706]},{类型:特征,属性:{dbh:6},几何:{类型:点,坐标:[-79.93512,40.42297]},{类型:特征,属性:{dbh:11},几何:{类型:点,坐标:[-79.948]{dbh:5},几何:{type:Point,座标:[79.96532,40.46236]},{type:Feature,properties:{dbh:9},几何:{type:Point,座标:[-80.02626,40.46095]},{type:Feature,properties:{dbh:28},几何:{type:Point,座标:[-79.89643,40.4709]},{type:Feature,properties:{dbh:33},几何:{type:Point 89923,139},{type:Feature,properties:{dbh:23},geometry:{type:Point,座标:[-79.93075,40.4537]},{type:Feature,properties:{dbh:27},geometry:{type:Point,座标:[-79.97275,40.4092]},{type:Feature,座标:[-79.97291,40.42903]},geometry:{type:Feature dbh:9},座标:{type:Point[-80.05702,40.45931]},{type:Feature,properties:{dbh:21},geometry:{type:Point,坐标:[-79.91458,40.37661]},{type:Feature,properties:{dbh:3},geometry:{type:Point,坐标:[-79.98257,40.43163]},{type:Feature dbh:12},geometry:{type:Point,坐标:[-79.99182,40.42098]},geometry:{type:dbh:8}{type:Point,坐标:[-80.02467,40.42132]},{type:Feature,properties:{dbh:3},geometry:{type:Point,坐标:[-79.99538,40.41503]},{type:Feature,properties:{dbh:11},geometry:{type:Point,坐标:[-80.01479,40.43473]},geometry:{type:Feature dbh:10},geometry:{type:Point,坐标:[-80.0249,40.455},properties:{dbh:,几何:{type:Point,坐标:[-80.0169,40.40108]},{type:Feature,properties:{dbh:30},几何:{type:Point,坐标:[-80.02882,40.39472]},{type:Feature,properties:{dbh:26},几何:{type:Point,坐标:[-80.05036,40.43446]},{type:Feature dbh:7},几何:{type:Point,坐标:[-80.04684]},{type:Feature,properties:{dbh:12},geometry:{type:Point,座标:[-80.03631,40.4451]},{type:Feature,properties:{dbh:19},geometry:{type:Point,座标:[-80.05068,40.43413]},{type:Feature properties:{dbh:16},geometry:{type:Point,座标:[-79.95617,40.46891]},{type:Feature dbh:8},座标:[-80.03394,40.43543]},{type:Feature,properties:{dbh:-1},geometry:{type:Point,座标:[-79.88155,40.45938]},{type:Feature,properties:{dbh:10},geometry:{type:Point,座标:[-79.92019,40.47594]},{type:Feature dbh:-1},geometry:{type:Point type:Point座标:[-79.89742,40.46995]},geometry:{type:dbh:23}{类型:点,坐标:[-80.01727,40.46422]}} };
您的路径应该是trees.geojson,没有./。您可以通过打开调试控制台的“网络”选项卡获得更多信息。如果出现404错误,则确实存在路径错误。

是否正在运行fr
本地web服务器?可能是浏览器限制,请检查浏览器控制台。