django-map-location


Namedjango-map-location JSON
Version 0.9.2 PyPI version JSON
download
home_pagehttps://github.com/relikd/django-map-location
SummaryDjango Map-Location Field
upload_time2024-07-02 22:27:47
maintainerNone
docs_urlNone
authorrelikd
requires_python>=3.6
licenseMIT
keywords openstreetmap osm leaflet django geo gps position location
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django: Map-Location

Adds a fully-static location field (Leaflet) to manage location-based data without the need for a full-fledged GeoDjango installation. ... when all you need is a visual position chooser.

![screenshot](screenshot.jpg)

Features: 
- Click on map or drag&drop pin to select location
- Reset button & use map-center button
- Display selected location or map center coordinates with zoom level


## Install

1. Add to your INSTALLED_APPS

```py
INSTALLED_APPS = [
    ...,
    'map_location',
]
```

2. Create Map-Location field

```py
from map_location.fields import LocationField

class Place(models.Model):
    location = LocationField('Pos', blank=True, null=True, options={
        'map': {
            'center': [52.52, 13.40],
            'zoom': 12,
        },
        # 'markerZoom': 18
        # 'tileLayer': 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
        # 'tileOptions': {
        #     attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>',
        # },
        # 'locate': {
        #     'showPopup': False,
        # },
    })
```


## Options Paramter

| Key         | Info
|-------------|------------------
| map         | [Map Options](https://leafletjs.com/reference.html#map-option) (default: `{center: [20, -25], zoom: 2}`)
| markerZoom  | Initial zoom scale (on load) – if a marker is set.  (default: `18`)
| tileLayer   | [TileLayer](https://leafletjs.com/reference.html#tilelayer) urlTemplate (default: `"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"`)
| tileOptions | [TileLayer Options](https://leafletjs.com/reference.html#tilelayer-option) (default: `{}`)
| locate      | [Leaflet.Locate Options](https://github.com/domoritz/leaflet-locatecontrol#possible-options) (default: `{showPopup: false}`)


## Usage

You can access the location by its parts (`place.location.lat` & `place.location.long`) or by its string value (`str(place.location)` or just `place.location`) which will return a comma-separated string (`lat,long`). This string format is also used for database storage (with a precision of 6 digits, or up to 11 cm).


## Example

If you export your location as json, you can use a fully static map:

```py
_JSON_ = {'loc': [place.location.lat, place.location.long]}
```

```html
<script src="/static/leaflet/leaflet.js"></script>
<script src="/static/leaflet/locate/L.Control.Locate.min.js"></script>
<link rel="stylesheet" href="/static/leaflet/leaflet.css" />
<link rel="stylesheet" href="/static/leaflet/locate/L.Control.Locate.css" />
...
<div id="map-id"></div>
...
<script>
    const osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');
    const map = L.map('map-id', {
        layers: [osm],
        center: [52.52, 13.40],
        zoom: 14,
    });
    L.control.locate({
        returnToPrevBounds: true,
        showPopup: false,
    }).addTo(map);
    L.marker(L.latLng(_JSON_.loc)).addTo(map);
    ...
</script>
```

See [Leaflet](https://leafletjs.com/) docs for configuration options.


## License

This project is licensed under MIT and includes:

- v1.9.4 [Leaflet](https://github.com/Leaflet/Leaflet) (BSD 2-Clause License)
- v0.81.1 [Leaflet.Locate](https://github.com/domoritz/leaflet-locatecontrol) (MIT)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/relikd/django-map-location",
    "name": "django-map-location",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "OpenStreetMap, OSM, Leaflet, Django, Geo, GPS, Position, Location",
    "author": "relikd",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/3c/fe/4326425dd755edef572c1ab6913f51decf4eb3ec30d9499af0fe03e6127e/django-map-location-0.9.2.tar.gz",
    "platform": null,
    "description": "# Django: Map-Location\n\nAdds a fully-static location field (Leaflet) to manage location-based data without the need for a full-fledged GeoDjango installation. ... when all you need is a visual position chooser.\n\n![screenshot](screenshot.jpg)\n\nFeatures: \n- Click on map or drag&drop pin to select location\n- Reset button & use map-center button\n- Display selected location or map center coordinates with zoom level\n\n\n## Install\n\n1. Add to your INSTALLED_APPS\n\n```py\nINSTALLED_APPS = [\n    ...,\n    'map_location',\n]\n```\n\n2. Create Map-Location field\n\n```py\nfrom map_location.fields import LocationField\n\nclass Place(models.Model):\n    location = LocationField('Pos', blank=True, null=True, options={\n        'map': {\n            'center': [52.52, 13.40],\n            'zoom': 12,\n        },\n        # 'markerZoom': 18\n        # 'tileLayer': 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',\n        # 'tileOptions': {\n        #     attribution: '\u00a9 <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>',\n        # },\n        # 'locate': {\n        #     'showPopup': False,\n        # },\n    })\n```\n\n\n## Options Paramter\n\n| Key         | Info\n|-------------|------------------\n| map         | [Map Options](https://leafletjs.com/reference.html#map-option) (default: `{center: [20, -25], zoom: 2}`)\n| markerZoom  | Initial zoom scale (on load) \u2013 if a marker is set.  (default: `18`)\n| tileLayer   | [TileLayer](https://leafletjs.com/reference.html#tilelayer) urlTemplate (default: `\"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\"`)\n| tileOptions | [TileLayer Options](https://leafletjs.com/reference.html#tilelayer-option) (default: `{}`)\n| locate      | [Leaflet.Locate Options](https://github.com/domoritz/leaflet-locatecontrol#possible-options) (default: `{showPopup: false}`)\n\n\n## Usage\n\nYou can access the location by its parts (`place.location.lat` & `place.location.long`) or by its string value (`str(place.location)` or just `place.location`) which will return a comma-separated string (`lat,long`). This string format is also used for database storage (with a precision of 6\u00a0digits, or up to 11\u00a0cm).\n\n\n## Example\n\nIf you export your location as json, you can use a fully static map:\n\n```py\n_JSON_ = {'loc': [place.location.lat, place.location.long]}\n```\n\n```html\n<script src=\"/static/leaflet/leaflet.js\"></script>\n<script src=\"/static/leaflet/locate/L.Control.Locate.min.js\"></script>\n<link rel=\"stylesheet\" href=\"/static/leaflet/leaflet.css\" />\n<link rel=\"stylesheet\" href=\"/static/leaflet/locate/L.Control.Locate.css\" />\n...\n<div id=\"map-id\"></div>\n...\n<script>\n    const osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');\n    const map = L.map('map-id', {\n        layers: [osm],\n        center: [52.52, 13.40],\n        zoom: 14,\n    });\n    L.control.locate({\n        returnToPrevBounds: true,\n        showPopup: false,\n    }).addTo(map);\n    L.marker(L.latLng(_JSON_.loc)).addTo(map);\n    ...\n</script>\n```\n\nSee [Leaflet](https://leafletjs.com/) docs for configuration options.\n\n\n## License\n\nThis project is licensed under MIT and includes:\n\n- v1.9.4 [Leaflet](https://github.com/Leaflet/Leaflet) (BSD 2-Clause License)\n- v0.81.1 [Leaflet.Locate](https://github.com/domoritz/leaflet-locatecontrol) (MIT)\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Django Map-Location Field",
    "version": "0.9.2",
    "project_urls": {
        "Homepage": "https://github.com/relikd/django-map-location"
    },
    "split_keywords": [
        "openstreetmap",
        " osm",
        " leaflet",
        " django",
        " geo",
        " gps",
        " position",
        " location"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d919830dfa32e4ccdc52f6ecce1714477801cf76f403270ab2f40169e33071bc",
                "md5": "36d3c5eccd56ed7bff069c4dffc23581",
                "sha256": "64b36b589085814756c4e712de4a85661978e76fb318d41c74364f5f62f97559"
            },
            "downloads": -1,
            "filename": "django_map_location-0.9.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "36d3c5eccd56ed7bff069c4dffc23581",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 151219,
            "upload_time": "2024-07-02T22:27:45",
            "upload_time_iso_8601": "2024-07-02T22:27:45.310918Z",
            "url": "https://files.pythonhosted.org/packages/d9/19/830dfa32e4ccdc52f6ecce1714477801cf76f403270ab2f40169e33071bc/django_map_location-0.9.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3cfe4326425dd755edef572c1ab6913f51decf4eb3ec30d9499af0fe03e6127e",
                "md5": "9dc47597138f0184b669409af6ec2734",
                "sha256": "30dbb846541d93a022fb62c34df1a733e3cde8df21a3ade05894d158e1a9a256"
            },
            "downloads": -1,
            "filename": "django-map-location-0.9.2.tar.gz",
            "has_sig": false,
            "md5_digest": "9dc47597138f0184b669409af6ec2734",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 148178,
            "upload_time": "2024-07-02T22:27:47",
            "upload_time_iso_8601": "2024-07-02T22:27:47.550492Z",
            "url": "https://files.pythonhosted.org/packages/3c/fe/4326425dd755edef572c1ab6913f51decf4eb3ec30d9499af0fe03e6127e/django-map-location-0.9.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-02 22:27:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "relikd",
    "github_project": "django-map-location",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "django-map-location"
}
        
Elapsed time: 0.24418s