python中的arcgis

brqmpdu1  于 2021-07-14  发布在  Java
关注(0)|答案(0)|浏览(206)

有没有办法在flask app中使用arcgis python api,检索 WebMap 并将其传递到模板html中显示?我可以在jupyter笔记本中看到它非常突出,但不知道如何为flask创建一个解决方法。
这是一个代码狙击手,我正试图合并成一些工作。python部分:

from flask import Flask
from flask import render_template
from flask_cors import CORS
from arcgis.gis import GIS
from arcgis.mapping import WebMap
from arcgis.widgets import MapView

app = Flask(__name__)
CORS(app)

def get_map():
    gis = GIS("https://pythonapi.playground.esri.com/portal", "arcgis_python", "amazing_arcgis_123")
    search_result = gis.content.search("title:Natural Disasters (FC only) Collection", item_type="Web Map")
    wm_item = search_result[0]
    web_map = WebMap(wm_item)
    map_view = MapView(gis, web_map, mode='2D')
    return map_view

@app.route('/')
def index():
    """Return the main page."""
    gis_map = get_map()
    return render_template('index.html',**locals())
...

在html中:

<body>
  <div id="map">{{ gis_map }}</div>

 </body>
</html>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题