django-mapbox-location-field


Namedjango-mapbox-location-field JSON
Version 2.1.0 PyPI version JSON
download
home_pagehttps://github.com/Simon-the-Shark/django-mapbox-location-field
Summarylocation field with MapInput widget for picking some location
upload_time2024-03-18 23:59:17
maintainer
docs_urlNone
authorSzymon Kowaliński
requires_python
licenseMIT License
keywords django widgets location geocoding map fields forms
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
 # django-mapbox-location-field
![Build status](https://github.com/Simon-the-Shark/django-mapbox-location-field/actions/workflows/tests.yml/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/Simon-the-Shark/django-mapbox-location-field/badge.svg?branch=master)](https://coveralls.io/github/Simon-the-Shark/django-mapbox-location-field?branch=master)
 ![PyPI](https://img.shields.io/pypi/v/django-mapbox-location-field.svg) ![PyPI - Downloads](https://img.shields.io/pypi/dm/django-mapbox-location-field)
 ****
 Simple in use **location model and form field** with **MapInput widget** for picking some location. Uses [mapbox gl js](https://docs.mapbox.com/mapbox-gl-js/), flexible map provider API. Fully compatible with bootstrap framework.
 ****
   
   
# Table of contents  
* [Why this?](#why-this)  
* [Live demo](#live-demo)  
* [Compatibility](#compatibility)  
* [Versions >1.4.0 note](#versions-140)  
* [Installation](#installation)  
* [Configuration](#configuration)  
* [Usage](#usage)  
  * [PLAIN (non-spatial) db](#plain-database)  
  * [SPATIAL db](#spatial-database)  
* [Customization](#customization)  
  * [map_attrs](#map_attrs)  
  * [bootstrap](#bootstrap)  
* [Admin interface usage](#admin-interface-usage)  
* [AddressAutoHiddenField](#addressautohiddenfield)  
* [Multiple fields usage](#multiple-fields-usage)  
* [Troubleshooting](#troubleshooting) 
* [Technologies](#technologies)  
  
# Why this?  
I was searching for some django location field which uses mapbox to use it in my project. However, I didn't find anything which suited my needs in 100% and that's why I created this simple django app. My philosophy was simplicity, but I wanted to create complete solution for picking location.  
  
Feel free to open issues, make pull request and request some features or instructions. Let me know if you think it is not flexible enough.
  
PyPi's funny statistics (downloads etc): https://pypistats.org/packages/django-mapbox-location-field
  
# Live demo  
Curious how it works and looks like? See live demo on https://dj-map-loc-field-demo.kowalinski.dev  
Demo app uses [django-bootstrap4](https://github.com/zostera/django-bootstrap4) for a little better looking form fields.  
You can also use it as a code example, because it is available on [my github](https://github.com/Simon-the-Shark/live_demo_django_mapbox_location_field).

# Compatibility
### Breaking changes
Since `v2.0.0` package supports only `Django` versions `3.x` and `4.x` and its relevant `Python` versions, due to breaking changes in Django api.
For Django `2.x` and `1.x`, you can use version `1.7.4` and below and it should work relatively well, but newest upgrades will not be applied.

Package automatically tested on Github Actions:
* Django `5.0.3`, `4.2` and `3.2.12`
* Python `3.10`, `3.11`, `3.12`  
   
#### Browser support  
django-mapbox-location-field support all browsers, which are supported by mapbox gl js. Read more [here](https://docs.mapbox.com/help/troubleshooting/mapbox-browser-support/#mapbox-gl-js)  
#### Databases support  
It should work with every **spatial** and **plain** (non-spatial) database, that works with django and geodjango.  
# Versions >1.4.0  
  Since version 1.4.0 the order of coordinates convention has been changed. Now the order is `longitude, latitude`. This change has been caused by support for spatial databases. Nevertheless, more user-friendly is order `latitude, longitude`(Google Maps uses it). That's why coordinates are falsely swapped in frontend and then after POST request in form field are swapped back into `longitude, latitude` order and saved to database.  
 My conclusion is that the location is falsely swapped in frontend and if you create location without our custom form field or just operate on a raw model in the backend, you will have to use the `longitude, latitude` order.  
 Versions before 1.4.0 always uses `latitude, longitude` order.  
# Installation  
Using pip:  
    `pip install django-mapbox-location-field`  
  
# Configuration  
* Add `"mapbox_location_field"` to `INSTALLED_APPS` in your settings file  
  
```python  
INSTALLED_APPS += ("mapbox_location_field",)  
```  
  
* Define [MAPBOX_KEY](https://docs.mapbox.com/help/how-mapbox-works/access-tokens/) in your settings file. This is vulnerable information which has to be passed to frontend, so it can be easily accessed by user. To ensure your safety, I would recommend using [url restrictions](https://docs.mapbox.com/help/how-mapbox-works/access-tokens/#url-restrictions) and [public scopes](https://docs.mapbox.com/help/how-mapbox-works/access-tokens/#scopes). More information on linked websites.  
```python  
MAPBOX_KEY = "pk.eyJ1IjoibWlnaHR5c2hhcmt5IiwiYSI6ImNqd2duaW4wMzBhcWI0M3F1MTRvbHB0dWcifQ.1sDAD43q0ktK1Sr374xGfw"  
```  
**PS. This above is only example access token. You have to paste here yours.**  
  
# Usage  
### PLAIN DATABASE  
 * Just create some model with LocationField.   
 ```python  
 from django.db import models  
 from mapbox_location_field.models import LocationField  
 class SomeLocationModel(models.Model):  
	 location = LocationField()  
 ```
### SPATIAL DATABASE  
 * Just create some model with SpatialLocationField.  
```python  
 from django.db import models 
 from mapbox_location_field.spatial.models import SpatialLocationField  
 class SomeLocationModel(models.Model):  
	 location = SpatialLocationField()    
 ```
* Create ModelForm  
 ```python  
 from django import forms 
 from .models import SomeLocationModel  
 class LocationForm(forms.ModelForm):  
	 class Meta:  
		 model = SomeLocationModel 
		 fields = "__all__" 
 ```  
 Of course, you can also use CreateView, UpdateView or build Form yourself with `mapbox_location_field.forms.LocationField` or `mapbox_location_field.spatial.forms.SpatialLocationField` 
* Then just use it in html view. It can't be simpler!  
Paste this in your html head:  
```django  
 {% load mapbox_location_field_tags %} 
 {% location_field_includes %}
 {% include_jquery %}
 ```
 * And this in your body:  
 ```django  
 <form method="post">
 {% csrf_token %} 
	{{form}}
	<input type="submit" value="submit"> 
</form> 
{{ form.media }}
 ```
 * Your form is ready! Start your website and see how it looks. If you want to change something look to the [customization](#customization) section.  
 
# Customization  
In order to change few things you have to use `map_attrs` dictionary.  
Default `map_attrs` looks like this:  
```python  
default_map_attrs = {  
 "style": "mapbox://styles/mapbox/outdoors-v11",
 "zoom": 13,
 "center": [17.031645, 51.106715],
 "cursor_style": 'pointer',
 "marker_color": "red",
 "rotate": False,
 "geocoder": True,
 "fullscreen_button": True,
 "navigation_buttons": True,
 "track_location_button": True, 
 "readonly": True,
 "placeholder": "Pick a location on map below", 
 "language": "auto",
 "message_404": "undefined address", }
 ```  
To change some values, just pass it when you create model.  
```python  
from django.db import models  
from mapbox_location_field.models import LocationField  
  
class SomeLocationModel(models.Model):  
    location = LocationField(map_attrs={"center": [0,0], "marker_color": "blue"})  
```  
## map_attrs  
* style - `<string>`, mapbox style url. Read more [here](https://docs.mapbox.com/help/glossary/style-url/).  
* zoom - `<int>`, map's zoom. Read more [here](https://docs.mapbox.com/help/glossary/zoom-level/).  
* center - `<list>` or `<tuple>` of `<float>`s, defaults map's center point in [`latitude`, `longitude`]  
* cursor_style - `<string>`, css cursor style. Read more [here](https://www.w3schools.com/cssref/pr_class_cursor.asp).  
* marker_color - `<string>` css color property. Read more [here](https://www.w3schools.com/cssref/css_colors_legal.asp)  and [here](https://www.w3schools.com/cssref/css_colors.asp).  
* rotate - `<bool>`, whether you can rotate the map with right mouse click or not.  
* geocoder -`<bool>`, whether geocoder searcher is showed or not.  
* fullscreen_button - `<bool>`, whether fullscreen button is showed or not.  
* navigation_buttons - `<bool>`, whether navigation buttons are showed or not.  
* track_location_button - `<bool>`, whether show my location button is showed or not.  
* readonly - `<bool>`, whether user can type location in text input  
* placeholder - `<string>`, text input's placeholder  
* id - `<string>`, unique id for the field, when you are using multiple fields (See more in [this section](#multiple-fields-usage)). When you use only one field, you don't have to define it, because default value is taken.  
* language - `<string>`, language of an address returned from geocoding queries. Default is `"auto"` - which lets mapbox gl js determine the language (usually browser language if available). Hovewer, you can specify it in case of need. Check out [language coverage section in mapbox docs](https://docs.mapbox.com/api/search/geocoding/#language-coverage) to see available options of this field.
* message_404 -  `<string>`, string used when no address is returned from geocoding query (e.q. marker on the ocean area). Default is simple: `"undefined address"`
  
## bootstrap  
MapInput widget is fully compatible with bootstrap library. I can even recommend using it with [django-bootstrap4](https://github.com/zostera/django-bootstrap4) or [django-crispy-forms](https://github.com/django-crispy-forms/django-crispy-forms).  
  
# Admin interface usage  
First create some model with location field like in [usage section](#usage).  
Then register it in admin interface like this:  
* #### Plain:  
```python  
from django.contrib import admin   
from .models import SomeLocationModel   
from mapbox_location_field.admin import MapAdmin   
  
admin.site.register(SomeLocationModel, MapAdmin)  
```  
* #### Spatial:  
```python  
from django.contrib import admin  
from .models import SomeLocationModel  
from mapbox_location_field.spatial.admin import SpatialMapAdmin  
  
admin.site.register(SomeLocationModel, SpatialMapAdmin)  
```  
* #### Admin customization:  
Since `v1.7.0` admin customization should work out of the box, automatically using the `map_attrs` from model definition. 
  
# AddressAutoHiddenField  
AddressAutoHiddenField is a field for storing address. It uses AddressAutoHiddenInput which is hidden and when you place your marker on the map, automatically fill itself with proper address.  
In order to use it just add it to your model. Something like this:  
```python  
class SomeLocationModel(models.Model):  
    location = LocationField()  
    address = AddressAutoHiddenField()  
```  
# Multiple fields usage  
Since version 1.6.0, it is now possible to use multiple LocationFields (or forms or widgets) as well as multiple AutoHiddenAddressFields. All you have to do is define unique `id` in `map_attrs`:  
```python  
location1 = LocationField(map_attrs={"id": "unique_id_1"})  
location2 = LocationField(map_attrs={"id": "unique_id_2"})  
```  
Then you can also use these ids as `map_id` in your AutoHiddenAddressFields:  
```python  
address1 = AddressAutoHiddenField(map_id="unique_id_1")  
address2 = AddressAutoHiddenField(map_id="unique_id_2")  
```  
# Troubleshooting  
* #### Usage of the plain field's value in javascript ( [Issue #21](https://github.com/Simon-the-Shark/django-mapbox-location-field/issues/21))
	In case of the plain field, the python representation of coordinates is a  [tuple](https://www.w3schools.com/python/python_tuples.asp). And e.g. Mapbox requires a [javascript's array](https://www.w3schools.com/js/js_arrays.asp) when placing a marker on a map, which has identical syntax as  [Python's list](https://www.w3schools.com/python/python_lists.asp). In order to make the transformation as easy as possible, since `v1.6.4` you can use a special filter or tag (
choose your preferred way)
	```Django
	{% load mapbox_location_field_tags %}
	<script>
		var lngLatWithFilter = {{object.location | tuple_to_array }};
		var lngLatWithTag = {% tuple_to_array object.location %};
	
	// These are just two ways, which give the same result
	// Now you can use one of this variables as an array
	</script>
	```
* #### [Address field's width and coordinates order convetions (Issue #30)](https://github.com/simon-the-shark/django-mapbox-location-field/issues/30)
 * Stackoverflow questions:
    * [Unable to show the data in django-mapbox-location-field Django
](https://stackoverflow.com/questions/66081209/unable-to-show-the-data-in-django-mapbox-location-field-django/66094192#66094192)
# Technologies  
* Django  
* Mapbox GL JS  
* jQuery  
* HTML and CSS

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Simon-the-Shark/django-mapbox-location-field",
    "name": "django-mapbox-location-field",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "DJANGO,WIDGETS,LOCATION,GEOCODING,MAP,FIELDS,FORMS",
    "author": "Szymon Kowali\u0144ski",
    "author_email": "contact@kowalinski.dev",
    "download_url": "https://files.pythonhosted.org/packages/c5/2b/67c9cabe9e152c59f6cc2492298602f286681577f81c929e21416c2dfbaf/django-mapbox-location-field-2.1.0.tar.gz",
    "platform": null,
    "description": "\n # django-mapbox-location-field\n![Build status](https://github.com/Simon-the-Shark/django-mapbox-location-field/actions/workflows/tests.yml/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/Simon-the-Shark/django-mapbox-location-field/badge.svg?branch=master)](https://coveralls.io/github/Simon-the-Shark/django-mapbox-location-field?branch=master)\n ![PyPI](https://img.shields.io/pypi/v/django-mapbox-location-field.svg) ![PyPI - Downloads](https://img.shields.io/pypi/dm/django-mapbox-location-field)\n ****\n Simple in use **location model and form field** with **MapInput widget** for picking some location. Uses [mapbox gl js](https://docs.mapbox.com/mapbox-gl-js/), flexible map provider API. Fully compatible with bootstrap framework.\n ****\n   \n   \n# Table of contents  \n* [Why this?](#why-this)  \n* [Live demo](#live-demo)  \n* [Compatibility](#compatibility)  \n* [Versions >1.4.0 note](#versions-140)  \n* [Installation](#installation)  \n* [Configuration](#configuration)  \n* [Usage](#usage)  \n  * [PLAIN (non-spatial) db](#plain-database)  \n  * [SPATIAL db](#spatial-database)  \n* [Customization](#customization)  \n  * [map_attrs](#map_attrs)  \n  * [bootstrap](#bootstrap)  \n* [Admin interface usage](#admin-interface-usage)  \n* [AddressAutoHiddenField](#addressautohiddenfield)  \n* [Multiple fields usage](#multiple-fields-usage)  \n* [Troubleshooting](#troubleshooting) \n* [Technologies](#technologies)  \n  \n# Why this?  \nI was searching for some django location field which uses mapbox to use it in my project. However, I didn't find anything which suited my needs in 100% and that's why I created this simple django app. My philosophy was simplicity, but I wanted to create complete solution for picking location.  \n  \nFeel free to open issues, make pull request and request some features or instructions. Let me know if you think it is not flexible enough.\n  \nPyPi's funny statistics (downloads etc): https://pypistats.org/packages/django-mapbox-location-field\n  \n# Live demo  \nCurious how it works and looks like? See live demo on https://dj-map-loc-field-demo.kowalinski.dev  \nDemo app uses [django-bootstrap4](https://github.com/zostera/django-bootstrap4) for a little better looking form fields.  \nYou can also use it as a code example, because it is available on [my github](https://github.com/Simon-the-Shark/live_demo_django_mapbox_location_field).\n\n# Compatibility\n### Breaking changes\nSince `v2.0.0` package supports only `Django` versions `3.x` and `4.x` and its relevant `Python` versions, due to breaking changes in Django api.\nFor Django `2.x` and `1.x`, you can use version `1.7.4` and below and it should work relatively well, but newest upgrades will not be applied.\n\nPackage automatically tested on Github Actions:\n* Django `5.0.3`, `4.2` and `3.2.12`\n* Python `3.10`, `3.11`, `3.12`  \n   \n#### Browser support  \ndjango-mapbox-location-field support all browsers, which are supported by mapbox gl js. Read more [here](https://docs.mapbox.com/help/troubleshooting/mapbox-browser-support/#mapbox-gl-js)  \n#### Databases support  \nIt should work with every **spatial** and **plain** (non-spatial) database, that works with django and geodjango.  \n# Versions >1.4.0  \n  Since version 1.4.0 the order of coordinates convention has been changed. Now the order is `longitude, latitude`. This change has been caused by support for spatial databases. Nevertheless, more user-friendly is order `latitude, longitude`(Google Maps uses it). That's why coordinates are falsely swapped in frontend and then after POST request in form field are swapped back into `longitude, latitude` order and saved to database.  \n My conclusion is that the location is falsely swapped in frontend and if you create location without our custom form field or just operate on a raw model in the backend, you will have to use the `longitude, latitude` order.  \n Versions before 1.4.0 always uses `latitude, longitude` order.  \n# Installation  \nUsing pip:  \n    `pip install django-mapbox-location-field`  \n  \n# Configuration  \n* Add `\"mapbox_location_field\"` to `INSTALLED_APPS` in your settings file  \n  \n```python  \nINSTALLED_APPS += (\"mapbox_location_field\",)  \n```  \n  \n* Define [MAPBOX_KEY](https://docs.mapbox.com/help/how-mapbox-works/access-tokens/) in your settings file. This is vulnerable information which has to be passed to frontend, so it can be easily accessed by user. To ensure your safety, I would recommend using [url restrictions](https://docs.mapbox.com/help/how-mapbox-works/access-tokens/#url-restrictions) and [public scopes](https://docs.mapbox.com/help/how-mapbox-works/access-tokens/#scopes). More information on linked websites.  \n```python  \nMAPBOX_KEY = \"pk.eyJ1IjoibWlnaHR5c2hhcmt5IiwiYSI6ImNqd2duaW4wMzBhcWI0M3F1MTRvbHB0dWcifQ.1sDAD43q0ktK1Sr374xGfw\"  \n```  \n**PS. This above is only example access token. You have to paste here yours.**  \n  \n# Usage  \n### PLAIN DATABASE  \n * Just create some model with LocationField.   \n ```python  \n from django.db import models  \n from mapbox_location_field.models import LocationField  \n class SomeLocationModel(models.Model):  \n\t location = LocationField()  \n ```\n### SPATIAL DATABASE  \n * Just create some model with SpatialLocationField.  \n```python  \n from django.db import models \n from mapbox_location_field.spatial.models import SpatialLocationField  \n class SomeLocationModel(models.Model):  \n\t location = SpatialLocationField()    \n ```\n* Create ModelForm  \n ```python  \n from django import forms \n from .models import SomeLocationModel  \n class LocationForm(forms.ModelForm):  \n\t class Meta:  \n\t\t model = SomeLocationModel \n\t\t fields = \"__all__\" \n ```  \n Of course, you can also use CreateView, UpdateView or build Form yourself with `mapbox_location_field.forms.LocationField` or `mapbox_location_field.spatial.forms.SpatialLocationField` \n* Then just use it in html view. It can't be simpler!  \nPaste this in your html head:  \n```django  \n {% load mapbox_location_field_tags %} \n {% location_field_includes %}\n {% include_jquery %}\n ```\n * And this in your body:  \n ```django  \n <form method=\"post\">\n {% csrf_token %} \n\t{{form}}\n\t<input type=\"submit\" value=\"submit\"> \n</form> \n{{ form.media }}\n ```\n * Your form is ready! Start your website and see how it looks. If you want to change something look to the [customization](#customization) section.  \n \n# Customization  \nIn order to change few things you have to use `map_attrs` dictionary.  \nDefault `map_attrs` looks like this:  \n```python  \ndefault_map_attrs = {  \n \"style\": \"mapbox://styles/mapbox/outdoors-v11\",\n \"zoom\": 13,\n \"center\": [17.031645, 51.106715],\n \"cursor_style\": 'pointer',\n \"marker_color\": \"red\",\n \"rotate\": False,\n \"geocoder\": True,\n \"fullscreen_button\": True,\n \"navigation_buttons\": True,\n \"track_location_button\": True, \n \"readonly\": True,\n \"placeholder\": \"Pick a location on map below\", \n \"language\": \"auto\",\n \"message_404\": \"undefined address\", }\n ```  \nTo change some values, just pass it when you create model.  \n```python  \nfrom django.db import models  \nfrom mapbox_location_field.models import LocationField  \n  \nclass SomeLocationModel(models.Model):  \n    location = LocationField(map_attrs={\"center\": [0,0], \"marker_color\": \"blue\"})  \n```  \n## map_attrs  \n* style - `<string>`, mapbox style url. Read more [here](https://docs.mapbox.com/help/glossary/style-url/).  \n* zoom - `<int>`, map's zoom. Read more [here](https://docs.mapbox.com/help/glossary/zoom-level/).  \n* center - `<list>` or `<tuple>` of `<float>`s, defaults map's center point in [`latitude`, `longitude`]  \n* cursor_style - `<string>`, css cursor style. Read more [here](https://www.w3schools.com/cssref/pr_class_cursor.asp).  \n* marker_color - `<string>` css color property. Read more [here](https://www.w3schools.com/cssref/css_colors_legal.asp)  and [here](https://www.w3schools.com/cssref/css_colors.asp).  \n* rotate - `<bool>`, whether you can rotate the map with right mouse click or not.  \n* geocoder -`<bool>`, whether geocoder searcher is showed or not.  \n* fullscreen_button - `<bool>`, whether fullscreen button is showed or not.  \n* navigation_buttons - `<bool>`, whether navigation buttons are showed or not.  \n* track_location_button - `<bool>`, whether show my location button is showed or not.  \n* readonly - `<bool>`, whether user can type location in text input  \n* placeholder - `<string>`, text input's placeholder  \n* id - `<string>`, unique id for the field, when you are using multiple fields (See more in [this section](#multiple-fields-usage)). When you use only one field, you don't have to define it, because default value is taken.  \n* language - `<string>`, language of an address returned from geocoding queries. Default is `\"auto\"` - which lets mapbox gl js determine the language (usually browser language if available). Hovewer, you can specify it in case of need. Check out [language coverage section in mapbox docs](https://docs.mapbox.com/api/search/geocoding/#language-coverage) to see available options of this field.\n* message_404 -  `<string>`, string used when no address is returned from geocoding query (e.q. marker on the ocean area). Default is simple: `\"undefined address\"`\n  \n## bootstrap  \nMapInput widget is fully compatible with bootstrap library. I can even recommend using it with [django-bootstrap4](https://github.com/zostera/django-bootstrap4) or [django-crispy-forms](https://github.com/django-crispy-forms/django-crispy-forms).  \n  \n# Admin interface usage  \nFirst create some model with location field like in [usage section](#usage).  \nThen register it in admin interface like this:  \n* #### Plain:  \n```python  \nfrom django.contrib import admin   \nfrom .models import SomeLocationModel   \nfrom mapbox_location_field.admin import MapAdmin   \n  \nadmin.site.register(SomeLocationModel, MapAdmin)  \n```  \n* #### Spatial:  \n```python  \nfrom django.contrib import admin  \nfrom .models import SomeLocationModel  \nfrom mapbox_location_field.spatial.admin import SpatialMapAdmin  \n  \nadmin.site.register(SomeLocationModel, SpatialMapAdmin)  \n```  \n* #### Admin customization:  \nSince `v1.7.0` admin customization should work out of the box, automatically using the `map_attrs` from model definition. \n  \n# AddressAutoHiddenField  \nAddressAutoHiddenField is a field for storing address. It uses AddressAutoHiddenInput which is hidden and when you place your marker on the map, automatically fill itself with proper address.  \nIn order to use it just add it to your model. Something like this:  \n```python  \nclass SomeLocationModel(models.Model):  \n    location = LocationField()  \n    address = AddressAutoHiddenField()  \n```  \n# Multiple fields usage  \nSince version 1.6.0, it is now possible to use multiple LocationFields (or forms or widgets) as well as multiple AutoHiddenAddressFields. All you have to do is define unique `id` in `map_attrs`:  \n```python  \nlocation1 = LocationField(map_attrs={\"id\": \"unique_id_1\"})  \nlocation2 = LocationField(map_attrs={\"id\": \"unique_id_2\"})  \n```  \nThen you can also use these ids as `map_id` in your AutoHiddenAddressFields:  \n```python  \naddress1 = AddressAutoHiddenField(map_id=\"unique_id_1\")  \naddress2 = AddressAutoHiddenField(map_id=\"unique_id_2\")  \n```  \n# Troubleshooting  \n* #### Usage of the plain field's value in javascript ( [Issue #21](https://github.com/Simon-the-Shark/django-mapbox-location-field/issues/21))\n\tIn case of the plain field, the python representation of coordinates is a  [tuple](https://www.w3schools.com/python/python_tuples.asp). And e.g. Mapbox requires a [javascript's array](https://www.w3schools.com/js/js_arrays.asp) when placing a marker on a map, which has identical syntax as  [Python's list](https://www.w3schools.com/python/python_lists.asp). In order to make the transformation as easy as possible, since `v1.6.4` you can use a special filter or tag (\nchoose your preferred way)\n\t```Django\n\t{% load mapbox_location_field_tags %}\n\t<script>\n\t\tvar lngLatWithFilter = {{object.location | tuple_to_array }};\n\t\tvar lngLatWithTag = {% tuple_to_array object.location %};\n\t\n\t// These are just two ways, which give the same result\n\t// Now you can use one of this variables as an array\n\t</script>\n\t```\n* #### [Address field's width and coordinates order convetions (Issue #30)](https://github.com/simon-the-shark/django-mapbox-location-field/issues/30)\n * Stackoverflow questions:\n    * [Unable to show the data in django-mapbox-location-field Django\n](https://stackoverflow.com/questions/66081209/unable-to-show-the-data-in-django-mapbox-location-field-django/66094192#66094192)\n# Technologies  \n* Django  \n* Mapbox GL JS  \n* jQuery  \n* HTML and CSS\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "location field with MapInput widget for picking some location",
    "version": "2.1.0",
    "project_urls": {
        "Download": "https://github.com/Simon-the-Shark/django-mapbox-location-field/archive/v2.1.0.tar.gz",
        "Homepage": "https://github.com/Simon-the-Shark/django-mapbox-location-field"
    },
    "split_keywords": [
        "django",
        "widgets",
        "location",
        "geocoding",
        "map",
        "fields",
        "forms"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c52b67c9cabe9e152c59f6cc2492298602f286681577f81c929e21416c2dfbaf",
                "md5": "bbd74811431b18047880b59dd7899ea0",
                "sha256": "0c4b798262339018b4816f2954b5581dfe3c8f91d463876616d78c23a5d21404"
            },
            "downloads": -1,
            "filename": "django-mapbox-location-field-2.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bbd74811431b18047880b59dd7899ea0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 18523,
            "upload_time": "2024-03-18T23:59:17",
            "upload_time_iso_8601": "2024-03-18T23:59:17.826264Z",
            "url": "https://files.pythonhosted.org/packages/c5/2b/67c9cabe9e152c59f6cc2492298602f286681577f81c929e21416c2dfbaf/django-mapbox-location-field-2.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-18 23:59:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Simon-the-Shark",
    "github_project": "django-mapbox-location-field",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-mapbox-location-field"
}
        
Elapsed time: 3.84365s