我有一个django-leaflet小部件,但是这个小部件显示了一些图像,而不是openlayers地图,我如何在modelform上更改它?
from django import forms
from django.contrib.gis.forms import OSMWidget, PointField, ModelForm
from leaflet.forms.widgets import LeafletWidget
class YourMapWidget(LeafletWidget):
geometry_field_class = 'geom'
class ApartmentForm(forms.ModelForm):
class Meta:
model = Apartment
fields = '__all__'
widgets = {'geom': YourMapWidget()}

发布于 2020-03-18 00:55:20
一种方法是使用设置全局更改它。如果您想使用OSM,只需在您的设置中添加类似以下内容,
LEAFLET_CONFIG = {
'DEFAULT_CENTER': (6.0, 45.0),
'DEFAULT_ZOOM': 16,
'TILES': 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
}顺便说一句,这实际上很奇怪,默认设置应该是OSM映射。
https://stackoverflow.com/questions/60721689
复制相似问题