GeoDjango provides some specialized form fields and widgets in order to visually display and edit geolocalized data on a map. By default, they use OpenLayers-powered maps, with a base WMS layer provided by NASA.
Sebagai tambahan pada form field arguments 1 biasa, bidang formulir GeoDjango mengambil argumen pilihan berikut.
GeoDjango form widgets allow you to display and edit geographic data on a
visual map.
Note that none of the currently available widgets supports 3D geometries, hence
geometry fields will fallback using a simple Textarea
widget for such data.
GeoDjango widgets are template-based, so their attributes are mostly different from other Django widget attributes.
BaseGeometryWidget.
geom_type
¶Jenis geometri OpenGis, umumnya disetel oleh bidang formulir.
BaseGeometryWidget.
map_height
¶BaseGeometryWidget.
map_width
¶Tinggi dan lebar dari peta widget (awalan adalah 400x600).
BaseGeometryWidget.
map_srid
¶Kode SRID digunakan oleh peta (awalan adalah 4326).
BaseGeometryWidget.
display_raw
¶Boolean value specifying if a textarea input showing the serialized
representation of the current geometry is visible, mainly for debugging
purposes (default is False
).
BaseGeometryWidget.
supports_3d
¶Menunjukkan jika edisi dukungan widget dari data 3D (awalan adalah False
).
BaseGeometryWidget.
template_name
¶Cetakan digunakan untuk membangun widget peta.
Anda dapat melewatkan atribut widget dalam cara sama yang untuk widget Django apapun. Sebagai contoh:
from django.contrib.gis import forms
class MyGeoForm(forms.Form):
point = forms.PointField(widget=
forms.OSMWidget(attrs={'map_width': 800, 'map_height': 500}))
BaseGeometryWidget
BaseGeometryWidget
¶Ini adalah sebuah widget dasar jelas mengandung logika dibutuhkan oleh sub kelas. Anda tidak dapat secara langsung menggunakan widget ini untuk bidang geometri. Cata bahwa pembangunan dari widget GeoDjango berdasarkan pada sebuah cetakan, dicirikan oleh atribut kelas template_name
.
OpenLayersWidget
OpenLayersWidget
¶Ini adalah widget awalan digunakan oleh semua bidang formulir GeoDjango. template_name
adalah gis/openlayers.html
.
OpenLayersWidget
and OSMWidget
use the openlayers.js
file
hosted on the cdnjs.cloudflare.com
content-delivery network. You can
subclass these widgets in order to specify your own version of the
OpenLayers.js
file tailored to your needs in the js
property of
the inner Media
class (see Aset sebagai pengertian tetap).
Older versions use OpenLayers.js
from openlayers.org
which
isn't suitable for production use since it offers no guaranteed uptime
and runs on a slow server.
Juga, widget sekarang menggunakan OpenLayer 3 daripada OpenLayer 2.
OSMWidget
OSMWidget
¶Widget ini menggunakan lapisan dasar OpenStreetMap untuk menampilkan obyek geografik. Atribut-atribut adalah:
template_name
¶gis/openlayers-osm.html
default_lat
¶default_lon
¶The default center latitude and longitude are 47
and 5
,
respectively, which is a location in eastern France.
The OpenLayersWidget
note about JavaScript file hosting above also
applies here. See also this FAQ answer about https
access to map
tiles.
OpenLayers 2.x has been dropped in favor of OpenLayers 3. If you extend
the gis/openlayers-osm.html
template, please review your custom
template.
Des 02, 2017