Improved widgets for Django's PointField
Project description
django-osm-widgets
Improved widgets for Django's PointField.
LatLonOpenlayersOSMWidget handles latitude and longitude inputs synced with the point on the map.
Requirements
- Python 3.10+
- Django >=3.0, <5.2
Installation
- run
pip install django-osm-widgets - add
django_osm_widgetsto yourINSTALLED_APPS
Usage
In your forms, use the widget like this:
from django.contrib.gis.forms.fields import PointField
from django_osm_widgets.fields import LatLonOpenlayersOSMWidget
class MyForm(forms.Form):
location = PointField(widget=LatLonOpenlayersOSMWidget)
The latitute and longitude fields will be automatically added in your page.
Customizations
You can define some options as in the example below.
When using "must_display_latlon_fields": False, your are responsible for providing two input fields in your page. These fields must have ids corresponding to latitude_field_id and longitude_field_id values (defaults to id_osm_widget_latitude and id_osm_widget_longitude).
import json
from django.contrib.gis.forms.fields import PointField
from django_osm_widgets.fields import LatLonOpenlayersOSMWidget
class MyForm(forms.Form):
location = PointField(
widget=LatLonOpenlayersOSMWidget(
attrs={
"must_display_latlon_fields": False,
"map_width": "auto",
"map_height": "auto",
"default_lat": 45,
"default_lon": 5,
"default_zoom": 8,
"latitude_field_id": "id_osm_widget_latitude",
"longitude_field_id": "id_osm_widget_longitude",
"listened_events": "input",
"marker_options": json.dumps({
"src": "/static/django_osm_widgets/marker.svg",
"scale": 1.5,
"anchor": [0.5, 1],
})
}
)
)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_osm_widgets-0.0.1.tar.gz.
File metadata
- Download URL: django_osm_widgets-0.0.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bc186c863f45627fac18b54a343ea1c3e6b2667161787781bff800fc09a3d8a
|
|
| MD5 |
e38bbf68ba0fa9e1bd95cb9876f8fcb4
|
|
| BLAKE2b-256 |
50418ad6d80e149f12c7ec2ac4a440ac3c2ac86bcab27eefa53062d8e45e577a
|
File details
Details for the file django_osm_widgets-0.0.1-py3-none-any.whl.
File metadata
- Download URL: django_osm_widgets-0.0.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ec7cb19a8da41d8d6718f6bd3ece3031e39af8f504a0f4cfe7e6f4e226f2bbd
|
|
| MD5 |
00658c9af56b616822ee298ed8f17def
|
|
| BLAKE2b-256 |
5294cea857e8c628c1f4745ebe33e868f9faf2bce03e1a8d7632b2f0c901ed75
|