A small gesture, a big support! Buy me a coffee β if you appreciate my work. Thanks in advance!
A complete Django application for managing and displaying interactive maps and floor plans with role-based authentication.
- π Features
- π οΈ Technologies Used
- π¦ Installation
- βοΈ Configuration
- πββοΈ Quick Start
- π Usage
- ποΈ Project Architecture
- π₯ Role System
- ποΈ File Structure
- π€ Contribution
- π License
- Interactive map visualization with Leaflet.js
- Floor plan display with layered navigation
- Custom markers with informative popups
- Polygon support to delineate areas
- 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)
- 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
- Django 5.1+ - Python web framework
- SQLite - Database (development)
- Python 3.8+ - Programming language
- Bootstrap 5 - Responsive CSS framework
- Leaflet.js - Interactive map library
- JavaScript ES6+ - Dynamic Interactions
- Font Awesome - Vector Icons
- Sortable.js - Drag and drop to reorder
- JSON - Map configuration storage
- 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.gitpip install poetryInstall all packages
poetry installGo to your floorproject folder and type
cd floorproject
python manage.py runserverCredientials are admin and admin
The project uses two main JSON files for 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"
}
}
}{
"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"
}
}
]
}Create a .env file for sensitive configurations :
SECRET_KEY=your_django_secret_key
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1- Access the application
- Public interface:
http://localhost:8000/ - Admin interface:
http://localhost:8000/administrator/ - Login:
http://localhost:8000/login/
- 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
- Viewing Maps
- Go to the "Mapping" β "Map" section
- Click on markers to view information
- Use the zoom and navigation controls
- Viewing Plans
- Go to the "Mapping" β "Plans" section
- Use the layer selector to change floors
- Navigate plans with Leaflet controls
- User Management
- Create accounts with different roles
- Assign appropriate permissions
- Manage user active/inactive status
- Editing Maps
- Change the default view (center, zoom)
- Create and manage custom icons
- Add markers and polygons
- Test in real time on the map
- Plan Management
- Upload plan images
- Configure limits and settings
- Organize the display order
- Associate markers with floors
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
Floor plans with markers
Admin interface where you select GPS coordinates or floor coordinates You can add edit and delete marker icon et location You can draw polygon.
Maanger user and role : admin, carte or plan
The project implements a three-tiered role system:
- Full permissions on all features
- User and role management
- Access to all editing sections
- File upload and deletion
- Edit global maps only
- Manage markers and icons for maps
- View all sections
- Edit floor plans only
- Manage markers associated with plans
- View all sections
@role_required(['admin', 'map']) # Only admin and map can access
def administrator_edit_map(request):
# Code for the view...| 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 |
| 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 |
- Draw mode enabled when clicking on the coordinate field
- Real-time preview during creation
- Automatic validation of JSON format
- Seamless integration with the interface
- Uniqueness check of names/IDs in real time
- Visual feedback with colored messages
- Duplicate prevention before saving
- Automatic prefixes by category
- Preview of uploaded images
- AJAX deletion without reloading
- Format validation (PNG, JPG, JPEG)
Contributions are welcome! Here's how to participate:
- Fork the project
- Create a branch for your feature (git checkout -b feature/AmazingFeature)
- Commit your changes (git commit -m 'Add some AmazingFeature')
- Push to the branch (git push origin feature/AmazingFeature)
- Open a Pull Request
- Respect existing code style
- Add comments for Python beginners
- Test your changes before submitting
- Document new features
If you find a bug, please:
- Check that it doesn't already exist in the issues
- Create a new issue with:
- Detailed description of the problem
- Steps to reproduce
- Screenshots if relevant
- Python/Django version used
This project is licensed under the MIT License. See the LICENSE file for more details.
β Please rate this project if it helps you!