{ "info": { "author": "Szymon Kowali\u0144ski", "author_email": "simonrekin@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.11", "Framework :: Django :: 2.0", "Framework :: Django :: 2.1", "Framework :: Django :: 2.2", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development", "Topic :: Software Development :: Libraries :: Application Frameworks" ], "description": "# django-mapbox-location-field\n [](https://travis-ci.org/Simon-the-Shark/django-mapbox-location-field) [](https://coveralls.io/github/Simon-the-Shark/django-mapbox-location-field?branch=master)\n \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 * [Instalation](#instalation)\n* [Configuration](#configuration)\n* [Usage](#usage)\n* [Customization](#customization)\n * [map_attrs](#map_attrs)\n * [bootstrap](#bootstrap)\n* [Admin interface usage](#admin-interface-usage)\n* [AddressAutoHiddenField](#addressautohiddenfield)\n* [Technologies](#technologies)\n\n# Why this?\nI was searching for some django location field which uses mapbox and I could use in my project. I didn't find anything which suits my needs in 100% and that is why I created this simple django app. My philosopy 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 enought.\n# Compatibility\nAutomatically tested on Travis CI on versions:\n\n* Django 1.11, 2.0, 2.1, 2.2\n* Python 3.5, 3.6, 3.7\n\nPS. Django 1.11 does not support Python 3.7 anymore.\n\n#### Browser support\ndjango-mapbox-location-field support all browsers, which are suported by mapbox gl js. Read more [here](https://docs.mapbox.com/help/troubleshooting/mapbox-browser-support/#mapbox-gl-js)\n\n# Live demo\nCurious how it works and looks like ? See live demo on https://django-mapbox-location-field.herokuapp.com\nDemo app uses [django-bootstrap4](https://github.com/zostera/django-bootstrap4) for a little better looking form fields.\n\n# Instalation\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 access 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* Just create some model with LocationField.\n```python\nfrom django.db import models\nfrom mapbox_location_field.models import LocationField\n\nclass SomeLocationModel(models.Model):\n location = LocationField()\n\n```\n* Create ModelForm\n```python\nfrom django import forms\nfrom .models import Location\n\nclass LocationForm(forms.ModelForm):\n class Meta:\n model = Location\n fields = \"__all__\"\n```\nOf course you can also use CreateView, UpdateView or build Form yourself with mapbox_location_field.forms.LocationField\n\n\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
\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 }\n```\nTo change some values, just pass it when you creates model.\n```python\nfrom django.db import models\nfrom mapbox_location_field.models import LocationField\n\nclass Location(models.Model):\n location = LocationField(map_attrs={\"center\": [0,0], \"marker_color\": \"blue\"})\n```\n## map_attrs\n* style - `