---
title: "API Formulir GeoDjango"
version: 1.11
locale: id
source: https://docs.djangoproject.com/id/1.11/ref/contrib/gis/forms-api/
canonical: https://djangodocs.dev/id/1.11/ref/contrib/gis/forms-api/
---
# API Formulir GeoDjango

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](http://openlayers.org/)-powered maps, with a base WMS layer provided by [NASA](https://earthdata.nasa.gov/).

## Argumen bidang

Sebagai tambahan pada form field arguments 1 biasa, bidang formulir GeoDjango mengambil argumen pilihan berikut.

### `srid`

#### `Field.srid`

This is the SRID code that the field value should be transformed to. For
example, if the map widget SRID is different from the SRID more generally
used by your application or database, the field will automatically convert
input values into that SRID.

### `geom_type`

#### `Field.geom_type`

You generally shouldn't have to set or change that attribute which should
be setup depending on the field class. It matches the OpenGIS standard
geometry name.

## Kelas-kelas bidang formulir

### `GeometryField`

#### `class GeometryField`

### `PointField`

#### `class PointField`

### `LineStringField`

#### `class LineStringField`

### `PolygonField`

#### `class PolygonField`

### `MultiPointField`

#### `class MultiPointField`

### `MultiLineStringField`

#### `class MultiLineStringField`

### `MultiPolygonField`

#### `class MultiPolygonField`

### `GeometryCollectionField`

#### `class GeometryCollectionField`

## Widget formulir

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.

### Atribut widget

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}))
```

### Kelas-kelas widget

`BaseGeometryWidget`

#### `class 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`](#django.contrib.gis.forms.widgets.BaseGeometryWidget.template_name).

`OpenLayersWidget`

#### `class OpenLayersWidget`

Ini adalah widget awalan digunakan oleh semua bidang formulir GeoDjango. `template_name` adalah `gis/openlayers.html`.

`OpenLayersWidget` and [`OSMWidget`](#django.contrib.gis.forms.widgets.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](http://openlayers.org/en/latest/doc/tutorials/custom-builds.html) in the `js` property of
the inner `Media` class (see [Aset sebagai pengertian tetap](/id/1.11/topics/forms/media/#assets-as-a-static-definition)).

> **Changed in Django 1.11**
>
> 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`

#### `class 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`](#django.contrib.gis.forms.widgets.OpenLayersWidget) note about JavaScript file hosting above also
applies here. See also this [FAQ answer](https://help.openstreetmap.org/questions/10920/how-to-embed-a-map-in-my-https-site) about `https` access to map
tiles.

> **Changed in Django 1.11**
>
> 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.
