Python Dash应用程序未将GeoJSON对象加载为源

Python Dash应用程序未将GeoJSON对象加载为源,python,Python,我正在开发一个Dash应用程序,该应用程序是根据此处找到的示例应用程序()建模的。该应用程序提供了一个指向从GitHub用户内容读取的GeoJSON文件的链接,以构建地图图层 base_url = "https://raw.githubusercontent.com/jackparmer/mapbox-counties/master/" for bin in BINS: geo_layer = dict( sourcetype="geojson",

我正在开发一个Dash应用程序,该应用程序是根据此处找到的示例应用程序()建模的。该应用程序提供了一个指向从GitHub用户内容读取的GeoJSON文件的链接,以构建地图图层

    base_url = "https://raw.githubusercontent.com/jackparmer/mapbox-counties/master/"
for bin in BINS:
    geo_layer = dict(
        sourcetype="geojson",
        source=base_url + str(year) + "/" + bin + ".geojson", <-- HERE
        type="fill",
        color=cm[bin],
        opacity=DEFAULT_OPACITY,
        # CHANGE THIS
        fill=dict(outlinecolor="#afafaf"),
    )
    layout["mapbox"]["layers"].append(geo_layer)
根据文档,GeoJSON对象可以作为源传递。因此,我是这样做的

        geo_df = (df_cur[(df_cur['val_bins'] == str(bin))]).copy() # geo
    geo_json=make_geo_json(geo_df)
    geo_layer = dict(
        sourcetype="geojson",
        source=geo_json,
        type="fill",
        color=cm[bin],
        opacity=DEFAULT_OPACITY,
        # CHANGE THIS
        fill=dict(outlinecolor="#afafaf"),
    )
尽管构造了它并且它的类型正确,但它没有显示


在使用原始源代码进行大量调试和比较后,我发现问题出在多边形的坐标上。如果访问下面的代码部分,您将看到坐标周围有两个箭头。这些表示问题所在。我通过简单地将我创建的数组添加到另一个数组来解决这个问题。从而实现“坐标”:-->[[-74.734949,39.727779],…[-74.548733,39.295101]]——正确嵌套

{"features": [{"geometry": {"coordinates": --->[[-74.734949, 39.727779], [-74.417286, 39.557994], [-74.313224, 39.497748], [-74.548733, 39.295101], [-74.860918, 39.322485], [-74.986888, 39.514178], [-74.877349, 39.607286], [-74.734949, 39.727779]], "geometry": [[-74.734949, 39.727779], [-74.417286, 39.557994], [-74.313224, 39.497748], [-74.548733, 39.295101], [-74.860918, 39.322485], [-74.986888, 39.514178], [-74.877349, 39.607286], [-74.734949, 39.727779]]<---, "type": "Polygon"}, "properties": {}, "type": "Feature"}], "type": "FeatureCollection"}

{“特征”:[{“几何”:{“坐标”:-->[-74.734949,39.727779],-74.417286,39.557994],-74.313224,39.497748],-74.548733,39.295101],-74.860918,39.322485],-74.986888,39.514178],-74.877349,39.607286],-74.734949,39.727779],“几何体”:[-74.734949,39.727779],-74.74747474747279],-7474747474747474747474747474747279],-,-7474747474747474747474747474747474747474747474747474747279],,,-7474747474,[-74.548733, 39.295101], [-74.860918, 39.322485], [-74.986888, 39.514178], [-74.877349, 39.607286], [-74.734949, 39.727779]]在使用原始源代码进行大量调试和比较后,我发现问题出在多边形的坐标上。如果您访问下面的代码部分,您将看到坐标周围有两个箭头。这些箭头表示问题点。我通过简单地将创建的数组添加到另一个数组中来解决此问题。从而实现“坐标”:-->[[-74.734949,39.727779],…[-74.548733,39.295101]]——正确嵌套

{"features": [{"geometry": {"coordinates": --->[[-74.734949, 39.727779], [-74.417286, 39.557994], [-74.313224, 39.497748], [-74.548733, 39.295101], [-74.860918, 39.322485], [-74.986888, 39.514178], [-74.877349, 39.607286], [-74.734949, 39.727779]], "geometry": [[-74.734949, 39.727779], [-74.417286, 39.557994], [-74.313224, 39.497748], [-74.548733, 39.295101], [-74.860918, 39.322485], [-74.986888, 39.514178], [-74.877349, 39.607286], [-74.734949, 39.727779]]<---, "type": "Polygon"}, "properties": {}, "type": "Feature"}], "type": "FeatureCollection"}
{“特征”:[{“几何”:{“坐标”:-->[-74.734949,39.727779],-74.417286,39.557994],-74.313224,39.497748],-74.548733,39.295101],-74.860918,39.322485],-74.986888,39.514178],-74.877349,39.607286],-74.734949,39.727779],“几何体”:[-74.734949,39.727779],-74.74747474747279],-7474747474747474747474747474747279],-,-7474747474747474747474747474747474747474747474747474747279],,,-7474747474,[-74.548733, 39.295101], [-74.860918, 39.322485], [-74.986888, 39.514178], [-74.877349, 39.607286], [-74.734949, 39.727779]]