查看配置环境:
Django 2.0.12+xadmin/admin+GeoDjango
起初不能显示地图报错:
Uncaught ReferenceError: ol is not defined
var base_layer = new ol.layer.Tile({
source: new ol.source.XYZ({
查看引用的js文件不知道为何跑最后去了,然后在openlayers.html模板中引入两个js文件,OK:
<script src="https://cdn.bootcss.com/openlayers/3.20.1/ol.js"></script>
<script type="text/javascript" src="/static/gis/js/OLMapWidget.js"></script>
<div id="{
{ id }}_div_map">
<div id="{
{ id }}_map"></div>
{% if not disabled %}<span class="clear_features"><a href="javascript:{
{ module }}.clearFeatures()">{% trans "Delete all Features" %}</a></span>{% endif %}
{% if display_raw %}<p>{% trans "Debugging window (serialized value)" %}</p>{% endif %}
<textarea id="{
{ id }}