I am new to web mapping. I am trying to display roads on my map, hence I build a server side application with flask, where I am selecting the roads table and saving the geometry column via AsGeoJson in Geojson format.
@app.route('/addstreet', methods=['GET', 'POST'])
def addstreet():
conn = g.db.cursor()
conn.execute('''select id,name,sub_type, AsGeoJSON(ST_GeomFromText(geom)) FROM roads''')
result = conn.fetchall()
result = json.dumps(result)
return result
Ok I saved my roads in an array like this:
$("#roads").click(function(event) {
//add streets
$.get(my_url, function( data ) {
features =[];
data = JSON.parse(data);
for (i=0; i< data.length; i++) {
roads = data[i][3];
features.push(roads);
}
console.log(features);
var myStyle = {
"color": "#ff7800",
"weight": 5,
"opacity": 0.999
};
L.geoJson(features, {
style: myStyle
}).addTo(map);
});
});
The error message is gone. But on my map I can't see any roads....