{"id":17172899,"url":"https://github.com/20tab/twentytab-gmaps-places","last_synced_at":"2025-04-13T16:12:59.518Z","repository":{"id":19746830,"uuid":"23003658","full_name":"20tab/twentytab-gmaps-places","owner":"20tab","description":"A django app on top of twentytab-gmaps and google maps api v3 to manage geolocation and markers with all the administrative level details","archived":false,"fork":false,"pushed_at":"2017-05-30T08:34:37.000Z","size":1890,"stargazers_count":2,"open_issues_count":2,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T07:11:14.577Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/20tab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-15T21:33:07.000Z","updated_at":"2017-04-06T17:19:45.000Z","dependencies_parsed_at":"2022-08-21T15:01:02.051Z","dependency_job_id":null,"html_url":"https://github.com/20tab/twentytab-gmaps-places","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Ftwentytab-gmaps-places","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Ftwentytab-gmaps-places/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Ftwentytab-gmaps-places/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/20tab%2Ftwentytab-gmaps-places/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/20tab","download_url":"https://codeload.github.com/20tab/twentytab-gmaps-places/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248537004,"owners_count":21120687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T23:48:42.122Z","updated_at":"2025-04-13T16:12:59.484Z","avatar_url":"https://github.com/20tab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"twentytab-gmaps-places\n=====================\n\n**This project is no longer maintained. Check https://github.com/20tab/django-political-map instead**\n\n\n\nA Django app on top of twentytab-gmaps and Google Maps api v3 to manage geolocation and markers with all the administrative level details.\n\n*Note: this app is alpha version.*\n\n## Installation\n\nUse the following command: ```pip install twentytab-gmaps-places```\n\n## Configuration\n\n```py\nINSTALLED_APPS = {\n    ...,\n    'gmapsmarkers',\n    'gmaps_places'\n    ...\n}\n\nGMAPS_API_KEY = \"xxxxxxxxxxxxxxxxxxxx\"\n\n```\n\nCheck twentytab-gmaps for parameters' settings:\nhttps://github.com/20tab/twentytab-gmaps\n\n```py\n\nSTATIC_URL = u'/static/'\nJQUERY_LIB = 'path_to_jquery'\nSELECT2_LIB = 'path_to_select2_js'\nSELECT2_CSS_LIB = 'path_to_select2_css'\nGMAPS_LANGUAGE_CODE = u'en'\n\n```\n\nYou can customize the gmaps types used to fill the\nutility fields and used in your url system.\n**Important**: be sure to set this parameters \naccording to the gmaps types\nhttps://developers.google.com/maps/documentation/javascript/geocoding#GeocodingAddressTypes\nand gmaps_places models\nhttps://github.com/20tab/twentytab-gmaps-places/blob/master/gmaps_places/models.py\n\nDefault values are:\n```py\nGMAPS_PLACES_ALLOWED_TYPES = ( \n    'country', 'administrative_area_level_1',\n    'administrative_area_level_2', 'administrative_area_level_3',\n    'administrative_area_level_4', 'administrative_area_level_5',\n    'locality', 'sublocality', 'neighborhood', 'premise', 'subpremise',\n    'postal_code', 'natural_feature', 'airport', 'park',\n    'street_address', 'route', 'intersection')\n\nGMAPS_PLACES_URL_TYPES = ( \n    'country', 'administrative_area_level_1',\n    'administrative_area_level_2', 'administrative_area_level_3',\n    'locality', 'sublocality')\n```\n\n\n- Static files\n\nRun collectstatic command or map static directory.\n\n## Usage\n\nmyapp/models.py\n```py\nfrom django.db import models\nfrom gmaps_places.models import GmapsPlace\n\n\nclass TestPlace(models.Model):\n    location = models.ForeignKey(GmapsPlace)\n\n    def __unicode__(self):\n        return u\"{}\".format(self.location)\n```\n\n## Example\n1. Create a ForeignKey to GmapsPlace in your model (e.g. as a \"location\" attribute)\n\n    ![ScreenShot](https://raw.github.com/20tab/twentytab-gmaps-places/master/img/screenshot1-models.png)\n\n2. Add a location simply by typing the address and clicking on the choosen marker, the app will automatically fill the administrative fields. *(the image is not updated to the latest version)*\n\n    ![ScreenShot](https://raw.github.com/20tab/twentytab-gmaps-places/master/img/screenshot2-address.png)\n    ![ScreenShot](https://raw.github.com/20tab/twentytab-gmaps-places/master/img/screenshot2b-address.png)\n\n3. Use *geo_type* to force a specific administrative level in case of homonymous. Example: \"Rome\" is administrative_area_level_2, _3 and locality, but you just need administrative_area_level_2 depth.\n\n    ![ScreenShot](https://raw.github.com/20tab/twentytab-gmaps-places/master/img/screenshot3-geo_type.png)\n\n4. Manage GmapsPlaces in their admin panels *(the image is not updated to the lates version)*\n\n    ![ScreenShot](https://raw.github.com/20tab/twentytab-gmaps-places/master/img/screenshot4-gmaps_places_admin.png)\n\n5. Manage and customize GmapsItems in their admin panels.\n\n    ![ScreenShot](https://raw.github.com/20tab/twentytab-gmaps-places/master/img/screenshot5-gmaps_items_admin.png)\n    ![ScreenShot](https://raw.github.com/20tab/twentytab-gmaps-places/master/img/screenshot5b-gmaps_items_admin.png)\n\n6. GmapsPlace contains all the administrative info, while GmapsItem contains all the gmaps data. Remember to use 'select_related' in your queries.\n\n    ```py\n    \u003e\u003e\u003e from test_places.models import TestPlace\n    \u003e\u003e\u003e example_place = TestPlace.objects.all().select_related('location', 'location__country_item')[0]\n    \u003e\u003e\u003e example_place\n    \u003cTestPlace: Via dei Fori Imperiali, Rome, Italy\u003e\n    \u003e\u003e\u003e example_place.location.country_item\n    \u003cGmapsItem: italy(country)\u003e\n    \u003e\u003e\u003e example_place.location.country_item.short_name\n    u'IT'\n    \u003e\u003e\u003e example_place.location.country_item.geometry_bounds\n    '{\"northeast\": {\"lat\": 47.092, \"lng\": 18.5205015}, \"southwest\": {\"lat\": 35.4929201, \"lng\": 6.6267201}}'\n    ```\n    Check the model definition for all the available attributes, properties, methods.\n\n7. The app includes sprite and css to easily generate flags (http://flag-sprites.com/) otherwise the **country_code** attribute can be used in a custom flags tool.\n\n    your_template.html\n    ```django\n    \u003clink rel=\"stylesheet\" href=\"{{ STATIC_URL }}flags/flags.css\"\u003e\n    ...\n    \u003cimg src=\"{{ STATIC_URL }}flags/blank.png\" class=\"flag flag-{{test_place.location.country_code|lower}}\"\u003e\n    ```\n8. As a further utility, you can use the GmapsPlacesForm in your frontend template in order to show just the address input with a map in your form without showing the foreign-key and the utility gmaps' fields.\n\n    ```py\n    from django.shortcuts import render_to_response\n    from django.template import RequestContext\n    from gmaps_places.forms import GmapsPlacesForm\n    from test_places.forms import TestPlaceForm\n    from gmaps_places.models import GmapsPlace\n    from test_places.models import TestPlace\n\n\n    def home(request):\n        status = None\n        if request.method == 'POST':\n            gpform = GmapsPlacesForm(request.POST)\n            test_places_form = TestPlaceForm(request.POST)\n            if gpform.is_valid() and test_places_form.is_valid():\n                place_id = gpform.cleaned_data['place_id']\n                new_gp, created = GmapsPlace.objects.get_or_create(\n                    place_id=place_id, defaults=gpform.cleaned_data)\n                new_tp, created = TestPlace.objects.get_or_create(\n                    location=new_gp, **test_places_form.cleaned_data)\n                status = 'OK'\n            else:\n                status = 'KO'\n        else:\n            gpform = GmapsPlacesForm()\n            test_places_form = TestPlaceForm()\n        return render_to_response(\n            'gptest.html',\n            {'gpform': gpform, 'test_places_form': test_places_form, 'status': status},\n            context_instance=RequestContext(request)\n        )\n    ```\n\n    ```django\n    \u003chtml\u003e\n        \u003chead\u003e\n            \u003ctitle\u003eGmapsPlaces Test\u003c/title\u003e\n            {{gpform.media}}\n        \u003c/head\u003e\n        \u003cbody\u003e\n            \u003ch1\u003eTEST GmapsPlaces\u003c/h1\u003e\n            \u003ch2\u003eStatus: {{status}}\u003c/h2\u003e\n            \u003cform method=\"post\" action=\"\"\u003e{% csrf_token %}\n                {{test_places_form.as_p}}\n                {{gpform.as_p}}\n                \u003c!-- remember to explicitly print hidden inputs if you\n                     are not using the whole form rendering --\u003e\n                \u003cp\u003e\u003cinput type=\"submit\" value=\"Submit\"\u003e\u003c/p\u003e\n            \u003c/form\u003e\n        \u003c/body\u003e\n    \u003c/html\u003e\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F20tab%2Ftwentytab-gmaps-places","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F20tab%2Ftwentytab-gmaps-places","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F20tab%2Ftwentytab-gmaps-places/lists"}