如何解决如何使用FlaskPython将GeoJson数据发布到网页-未捕获的SyntaxError:意外令牌'&'“
我的flask网络应用程序在将geoJson文件发布到前端时遇到了麻烦。
烧瓶代码:
geojson_sample = {
"type": "FeatureCollection","features": [
{
"type": "Feature","properties": {
"icon": "http://maps.google.com/mapfiles/ms/micons/pink-pushpin.png","marker-color": "#7e7e7e","marker-size": "medium","marker-symbol": "","Name": "Home"
},"geometry": {
"type": "Point","coordinates": [
150.84022521972656,-34.44315867450577
]
}
},{
"type": "Feature","Name": "Airport"
},"coordinates": [
150.79010009765625,-34.55888020163025
]
}
},"properties": {
"icon": "/static/img/marker/map-mark.png","Name": "Work"
},"coordinates": [
150.78632354736328,-34.33606548328852
]
}
}
]
}
@app.route("/test",methods=['GET','POST'])
def test():
return render_template("test.html",posts=geojson_sample)
test.html页面显示错误“未捕获的SyntaxError:意外的令牌'&'”
var geoJson = {'type': 'FeatureCollection','features': [{'type': 'Feature','properties': {'icon': 'http://maps.google.com/mapfiles/ms/micons/pink-pushpin.png','marker-color': '#7e7e7e','marker-size': 'medium','marker-symbol': '','Name': 'Home'},'geometry': {'type': 'Point','coordinates': [150.84022521972656,-34.44315867450577]}},{'type': 'Feature','Name': 'Airport'},'coordinates': [150.79010009765625,-34.55888020163025]}},'properties': {'icon': '/static/img/marker/map-mark.png','Name': 'Work'},'coordinates': [150.78632354736328,-34.33606548328852]}}]}
// var geoJson = {
// type: "FeatureCollection",// features: [
// {
// type: "Feature",// properties: {
// icon:
// "http://maps.google.com/mapfiles/ms/micons/pink-pushpin.png",// "marker-color": "#7e7e7e",// "marker-size": "medium",// "marker-symbol": "",// Name: "Home",// },// geometry: {
// type: "Point",// coordinates: [150.84022521972656,-34.44315867450577],// },// {
// type: "Feature",// Name: "Airport",// coordinates: [150.79010009765625,-34.55888020163025],// properties: {
// icon: "/static/img/marker/map-mark.png",// Name: "Work",// coordinates: [150.78632354736328,-34.33606548328852],// ],// };
function initMap() {
var map = new google.maps.Map(document.getElementById("map"),{
zoom: 8,center: {
lat: -34,lng: 150,},mapTypeId: google.maps.MapTypeId.TERRAIN,});
var markerCollection = map.data.addGeoJson(geoJson);
注意:它与带注释的var geoJson一起使用(如果我取消注释的话),但是当我从Flask发布它时却不能。任何想法表示赞赏:)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。