Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.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
Javascript GeoJson已正确呈现,但没有请求的颜色_Javascript_Jquery_Django_Leaflet_Geojson - Fatal编程技术网

Javascript GeoJson已正确呈现,但没有请求的颜色

Javascript GeoJson已正确呈现,但没有请求的颜色,javascript,jquery,django,leaflet,geojson,Javascript,Jquery,Django,Leaflet,Geojson,我有以下方法“ajax\u geojson”生成geo-json: geo_json = [ {"type": "Feature", "properties": { "id": c_name, "marker-color": "#f80530", "marker-size": "medium",

我有以下方法“ajax\u geojson”生成geo-json:

    geo_json = [ {"type": "Feature",
                    "properties": {
                        "id":  c_name,
                        "marker-color": "#f80530",
                        "marker-size": "medium",
                        "marker-symbol": "",
                        "popupContent":  content , 
                        }, 
                    "geometry": {
                        "type": "Point",
                        "coordinates": [lon, lat] }}
                    for c_name,content, lon,lat in zip(country_name, content, longtitude, latitude) ]     

   return JsonResponse(geo_json, safe=False)  
javascript使用jQuery呈现这一点:

              $.ajax({
                url: '/research/ajax_geojson',
                success: function (collection) 
                {                           
                   L.geoJson(collection, {onEachFeature: onEachFeature}).addTo(map);

                   function onEachFeature(feature, layer) 
                   {
                        if (feature.properties && feature.properties.popupContent) 
                        {
                            layer.bindPopup(feature.properties.popupContent); 
                        }  
                    }                       

                }
        }); 
虽然标记完全按照要求显示在地图上,但颜色似乎没有任何效果(f80530为红色)

我的问题是:在layer.bindpoop下有什么需要添加到javascript中的吗?我的印象是,在geo_json中定义颜色应该出现在地图中。我错过了什么

尝试在geo_json设置对象中的“几何体”后面添加“样式”对象:

    geo_json = [ {"type": "Feature",
                    "properties": {
                        "id":  c_name,
                        "marker-color": "#f80530",
                        "marker-size": "medium",
                        "marker-symbol": "",
                        "popupContent":  content , 
                        }, 
                    "geometry": {
                        "type": "Point",
                        "coordinates": [lon, lat] },
                    "style":{
                      //all SVG styles allowed
                      "fill":"red",
                      "stroke-width":"3",
                      "fill-opacity":0.6 }}
                    for c_name,content, lon,lat in zip(country_name, content, longtitude, latitude) ]     

   return JsonResponse(geo_json, safe=False)  

不。我以前尝试过这种风格。我没有做这个把戏:-(