Skip to content

yann83/MapProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Map Project

A small gesture, a big support! Buy me a coffee β˜• if you appreciate my work. Thanks in advance!

"Buy Me A Coffee"

A complete Django application for managing and displaying interactive maps and floor plans with role-based authentication.

Python Django License

πŸ“‹ Table of Contents

πŸš€ Features

🌐 Public Interface

  • Interactive map visualization with Leaflet.js
  • Floor plan display with layered navigation
  • Custom markers with informative popups
  • Polygon support to delineate areas

πŸ” Administration Interface

  • Authentication system with role management
  • Real-time map editor
  • Map Manager with image upload
  • Custom marker and icon management
  • File upload organized by category
  • User management (for administrators)

🎯 Advanced Features

  • Visual polygon editor by click
  • Real-time preview of changes
  • Drag-and-drop organization of maps
  • Real-time validation of forms
  • Responsive interface, mobile-friendly

πŸ› οΈ Technologies Used

Backend

  • Django 5.1+ - Python web framework
  • SQLite - Database (development)
  • Python 3.8+ - Programming language

Frontend

  • Bootstrap 5 - Responsive CSS framework
  • Leaflet.js - Interactive map library
  • JavaScript ES6+ - Dynamic Interactions
  • Font Awesome - Vector Icons

Tools and Libraries

  • Sortable.js - Drag and drop to reorder
  • JSON - Map configuration storage

πŸ“¦ Installation

Requirements

  • Python 3.8 or higher
  • pip (Python package manager)
  • Git

Externals assets :

  • bootstrap 5.3.3
  • fontawesome free 6.4.0
  • leaflet 1.9.4
git clone https://github.com/yann83/MapProject.git
pip install poetry

Install all packages

poetry install

Go to your floorproject folder and type

cd floorproject
python manage.py runserver

Credientials are admin and admin

βš™οΈ Configuration

JSON File Structure

The project uses two main JSON files for configuration:

static/json/global_map.json - Global Map Configuration

{
"setView": {
"lat": 43.12568,
"lng": 5.94334, 
"zoom": 18 
}, 
"icons": { 
"icon_name": { 
"iconUrl": "marker-icone.png", 
"iconSize": [25, 41], 
"iconAnchor": [12, 41], 
"popupAnchor": [1, -34] 
} 
}, 
"markers": { 
"marker_id": { 
"type": "marker", 
"coordinates": [43.12568, 5.94334], 
"popup": "Marker description", 
"icon": "icon_name" 
} 
}
}

static/json/maps.json - Configuring floor plans

{ 
"bounds": [[0, 0], [2339, 3309]],
"map": {
"minZoom": -5,
"zoomDelta": 0.25,
"zoomSnap": 0,
"layers": "floor1",
"xy": [1100, 1600],
"z": -2
},
"plans": {
"floor1": {
"name": "Floor 1",
"image": "plan-etage1.png"
}
},
"markers": [
{
"marker_id": {
"type": "marker",
"bound": "floor1",
"xy": [800, 400],
"popup": "Point of Interest",
"icon": "icon_name"
}
}
]
}

Environment Variables

Create a .env file for sensitive configurations :

SECRET_KEY=your_django_secret_key
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1

πŸƒβ€β™‚οΈ Quick Start

  1. Access the application
  • Public interface: http://localhost:8000/
  • Admin interface: http://localhost:8000/administrator/
  • Login: http://localhost:8000/login/
  1. First use
  • Log in with the created superuser
  • Upload your first images to /administrator/upload
  • Configure your maps in /administrator/edit/map
  • Add your plans to /administrator/edit/plans

πŸ“– Use

For End Users

  1. Viewing Maps
  • Go to the "Mapping" β†’ "Map" section
  • Click on markers to view information
  • Use the zoom and navigation controls
  1. Viewing Plans
  • Go to the "Mapping" β†’ "Plans" section
  • Use the layer selector to change floors
  • Navigate plans with Leaflet controls

For Administrators

  1. User Management
  • Create accounts with different roles
  • Assign appropriate permissions
  • Manage user active/inactive status
  1. Editing Maps
  • Change the default view (center, zoom)
  • Create and manage custom icons
  • Add markers and polygons
  • Test in real time on the map
  1. Plan Management
  • Upload plan images
  • Configure limits and settings
  • Organize the display order
  • Associate markers with floors

πŸ—οΈ Project architecture

floorproject/
β”œβ”€β”€ administrator/ # Admin app
β”‚ β”œβ”€β”€ templates/ # Admin HTML templates
β”‚ β”œβ”€β”€ templatetags/ # Custom template tags
β”‚ β”œβ”€β”€ models.py # Custom user model
β”‚ β”œβ”€β”€ views.py # Admin views
β”‚ β”œβ”€β”€ forms.py # Custom forms
β”‚ └── decorators.py # Security decorators
β”œβ”€β”€ public/ # Public app
β”‚ β”œβ”€β”€ templates/ # Public HTML templates
β”‚ └── views.py # Public Views
β”œβ”€β”€ floorproject/ # Main Configuration
β”‚ β”œβ”€β”€ static/ # Static Files
β”‚ β”‚ β”œβ”€β”€ css/ # CSS Styles
β”‚ β”‚ β”œβ”€β”€ js/ # JavaScript Scripts
β”‚ β”‚ β”œβ”€β”€ json/ # Map Configuration
β”‚ β”‚ β”œβ”€β”€ img/ # General Images
β”‚ β”‚ β”œβ”€β”€ markers/ # Marker Icons
β”‚ β”‚ └── plans/ # Map Images
β”‚ β”œβ”€β”€ settings.py # Django Configuration
β”‚ └── urls.py # Main Routing
└── manage.py # Django Management Script

Map from public interface, showing location of a building

public_map

Floor plans with markers

public_floorplan

Admin interface where you select GPS coordinates or floor coordinates You can add edit and delete marker icon et location You can draw polygon.

admin_menu

Maanger user and role : admin, carte or plan

admin_users

πŸ‘₯ Role System

The project implements a three-tiered role system:

πŸ”΄ Admin

  • Full permissions on all features
  • User and role management
  • Access to all editing sections
  • File upload and deletion

🟑 Map

  • Edit global maps only
  • Manage markers and icons for maps
  • View all sections

🟒 Plan

  • Edit floor plans only
  • Manage markers associated with plans
  • View all sections

Security Decorator

@role_required(['admin', 'map']) # Only admin and map can access
def administrator_edit_map(request):
# Code for the view...

πŸ—‚οΈ File Structure

Important Configuration Files

File Description Purpose
settings.py Django Configuration Global Settings, Database, Authentication
models.py Data Models Custom User System
global_map.json Global Map Config Markers, Icons, Default View
maps.json Map Config Floors, Boundaries, Markers per Map

Static Folders

Folder Contents Purpose
/static/markers/ Icons with marker- prefix Custom Markers
/static/plans/ Images with plan- prefix Floor plans
/static/json/ Configuration files Map settings

πŸš€ Advanced Features

Visual polygon editor

  • Draw mode enabled when clicking on the coordinate field
  • Real-time preview during creation
  • Automatic validation of JSON format
  • Seamless integration with the interface

Validation system

  • Uniqueness check of names/IDs in real time
  • Visual feedback with colored messages
  • Duplicate prevention before saving

Organized upload

  • Automatic prefixes by category
  • Preview of uploaded images
  • AJAX deletion without reloading
  • Format validation (PNG, JPG, JPEG)

🀝 Contribution

Contributions are welcome! Here's how to participate:

  1. Fork the project
  2. Create a branch for your feature (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Contributing Guidelines

  • Respect existing code style
  • Add comments for Python beginners
  • Test your changes before submitting
  • Document new features

πŸ› Bug Reporting

If you find a bug, please:

  1. Check that it doesn't already exist in the issues
  2. Create a new issue with:
  • Detailed description of the problem
  • Steps to reproduce
  • Screenshots if relevant
  • Python/Django version used

πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for more details.


⭐ Please rate this project if it helps you!

About

Map and Plan manager made with Djano and Leaflet

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published