Map Configuration¶
The Map system is a containerized web application that visualizes geographic data from NocoDB on an interactive map using Leaflet.js. It's designed for canvassing applications and community organizing.
Features¶
- πΊοΈ Interactive map visualization with OpenStreetMap
- π Real-time geolocation support for adding locations
- β Add new locations directly from the map interface
- π Auto-refresh every 30 seconds
- π± Responsive design for mobile devices
- π Secure API proxy to protect NocoDB credentials
- π€ User authentication with login system
- βοΈ Admin panel for system configuration
- π― Configurable map start location
- π Walk Sheet generator for door-to-door canvassing
- π QR code integration for digital resources
- π³ Docker containerization for easy deployment
- π 100% open source (no proprietary dependencies)
Setup Process Overview¶
The setup process involves several steps that must be completed in order:
- Get NocoDB API Token - Create an API token in your NocoDB instance
- Configure Environment - Update the
.envfile with your NocoDB details - Auto-Create Database Structure - Run the build script to create required tables
- Get Table URLs - Find and copy the URLs for the newly created tables
- Update Environment with URLs - Add the table URLs to your
.envfile - Build and Deploy - Build the Docker image and start the application
Prerequisites¶
- Docker and Docker Compose installed
- NocoDB instance with API access
- Domain name (optional but recommended for production)
Step 1: Get NocoDB API Token¶
- Login to your NocoDB instance
- Click your user icon β Account Settings
- Go to the API Tokens tab
- Click Create new token
- Set the following permissions:
- Read: Yes
- Write: Yes
- Delete: Yes (optional, for admin functions)
- Copy the generated token - you'll need it for the next step
Token Security
Keep your API token secure and never commit it to version control. The token provides full access to your NocoDB data.
Step 2: Configure Environment¶
Edit the .env file in the map/ directory:
# NocoDB API Configuration
NOCODB_API_URL=https://your-nocodb-instance.com/api/v1
NOCODB_API_TOKEN=your-api-token-here
# These URLs will be populated after running build-nocodb.sh
NOCODB_VIEW_URL=
NOCODB_LOGIN_SHEET=
NOCODB_SETTINGS_SHEET=
# Server Configuration
PORT=3000
NODE_ENV=production
# Session Secret (generate with: openssl rand -hex 32)
SESSION_SECRET=your-secure-random-string
# Map Defaults (Edmonton, Alberta, Canada)
DEFAULT_LAT=53.5461
DEFAULT_LNG=-113.4938
DEFAULT_ZOOM=11
# Optional: Map Boundaries (prevents users from adding points outside area)
# BOUND_NORTH=53.7
# BOUND_SOUTH=53.4
# BOUND_EAST=-113.3
# BOUND_WEST=-113.7
# Production Settings
TRUST_PROXY=true
COOKIE_DOMAIN=.yourdomain.com
ALLOWED_ORIGINS=https://map.yourdomain.com,http://localhost:3000
Required Configuration¶
NOCODB_API_URL: Your NocoDB instance API URL (usually ends with/api/v1)NOCODB_API_TOKEN: The token you created in Step 1SESSION_SECRET: Generate a secure random string for session encryption
Optional Configuration¶
DEFAULT_LAT/LNG/ZOOM: Default map center and zoom levelBOUND_*: Map boundaries to restrict where users can add pointsCOOKIE_DOMAIN: Your domain for cookie securityALLOWED_ORIGINS: Comma-separated list of allowed origins for CORS
Step 3: Auto-Create Database Structure¶
The build-nocodb.sh script will automatically create the required tables in your NocoDB instance.
What the Script Creates¶
The script creates three tables with the following structure:
1. Locations Table¶
Main table for storing map data:
Geo-Location(Geo-Data): Format "latitude;longitude"latitude(Decimal): Precision 10, Scale 8longitude(Decimal): Precision 11, Scale 8First Name(Single Line Text): Person's first nameLast Name(Single Line Text): Person's last nameEmail(Email): Email addressPhone(Single Line Text): Phone numberUnit Number(Single Line Text): Unit or apartment numberAddress(Single Line Text): Street addressSupport Level(Single Select): Options: "1", "2", "3", "4"- 1 = Strong Support (Green)
- 2 = Moderate Support (Yellow)
- 3 = Low Support (Orange)
- 4 = No Support (Red)
Sign(Checkbox): Has campaign signSign Size(Single Select): Options: "Small", "Medium", "Large"Notes(Long Text): Additional details and comments
2. Login Table¶
User authentication table:
Email(Email): User email address (Primary)Name(Single Line Text): User display nameAdmin(Checkbox): Admin privileges
3. Settings Table¶
Admin configuration table:
key(Single Line Text): Setting identifiertitle(Single Line Text): Display namevalue(Long Text): Setting valueGeo-Location(Text): Format "latitude;longitude"latitude(Decimal): Precision 10, Scale 8longitude(Decimal): Precision 11, Scale 8zoom(Number): Map zoom levelcategory(Single Select): Setting categoryupdated_by(Single Line Text): Last updater emailupdated_at(DateTime): Last update timeqr_code_1_image(Attachment): QR code 1 imageqr_code_2_image(Attachment): QR code 2 imageqr_code_3_image(Attachment): QR code 3 image
Default Data¶
The script also creates: - A default admin user (admin@example.com) - A default start location setting
Step 4: Get Table URLs¶
After the script completes successfully:
- Login to your NocoDB instance
- Navigate to your project (should be named "Map Viewer Project")
- For each table, get the view URL:
- Click on the table name
- Copy the URL from your browser's address bar
- The URL should look like:
https://your-nocodb.com/dashboard/#/nc/project-id/table-id
You need URLs for:
- Locations table β NOCODB_VIEW_URL
- Login table β NOCODB_LOGIN_SHEET
- Settings table β NOCODB_SETTINGS_SHEET
Step 5: Update Environment with URLs¶
Edit your .env file and add the table URLs:
# Update these with the actual URLs from your NocoDB instance
NOCODB_VIEW_URL=https://your-nocodb.com/dashboard/#/nc/project-id/locations-table-id
NOCODB_LOGIN_SHEET=https://your-nocodb.com/dashboard/#/nc/project-id/login-table-id
NOCODB_SETTINGS_SHEET=https://your-nocodb.com/dashboard/#/nc/project-id/settings-table-id
URL Format
Make sure to use the complete dashboard URLs, not the API URLs. The application will automatically extract the project and table IDs from these URLs.
Step 6: Build and Deploy¶
Build the Docker image and start the application:
Verify Deployment¶
-
Check that the container is running:
-
Check the logs:
-
Access the application at
http://localhost:3000(or your configured domain)
Using the Map System¶
User Interface¶
Main Map View¶
- Interactive Map: Click and drag to navigate
- Add Location: Click on the map to add a new location
- Search: Use the search bar to find addresses
- Refresh: Data refreshes automatically every 30 seconds
Location Markers¶
- Green: Strong Support (Level 1)
- Yellow: Moderate Support (Level 2)
- Orange: Low Support (Level 3)
- Red: No Support (Level 4)
Adding Locations¶
- Click on the map where you want to add a location
- Fill out the form with contact information
- Select support level and sign information
- Add any relevant notes
- Click "Save Location"
Authentication¶
User Login¶
- Users must be added to the Login table in NocoDB
- Login with email address (no password required for simplified setup)
- Admin users have additional privileges
Admin Access¶
- Admin users can access
/admin.html - Configure map start location
- Set up walk sheet generator
- Manage QR codes and settings
Admin Panel Features¶
Start Location Configuration¶
- Interactive Map: Visual interface for selecting coordinates
- Real-time Preview: See changes immediately
- Validation: Built-in coordinate and zoom level validation
Walk Sheet Generator¶
- Printable Forms: Generate 8.5x11 walk sheets for door-to-door canvassing
- QR Code Integration: Add up to 3 QR codes with custom URLs and labels
- Form Field Matching: Automatically matches fields from the main location form
- Live Preview: See changes as you type
- Print Optimization: Proper formatting for printing or PDF export
API Endpoints¶
Public Endpoints¶
GET /api/locations- Fetch all locations (requires auth)POST /api/locations- Create new location (requires auth)GET /api/locations/:id- Get single location (requires auth)PUT /api/locations/:id- Update location (requires auth)DELETE /api/locations/:id- Delete location (requires auth)GET /api/config/start-location- Get map start locationGET /health- Health check
Authentication Endpoints¶
POST /api/auth/login- User loginGET /api/auth/check- Check authentication statusPOST /api/auth/logout- User logout
Admin Endpoints (requires admin privileges)¶
GET /api/admin/start-location- Get start location with source infoPOST /api/admin/start-location- Update map start locationGET /api/admin/walk-sheet-config- Get walk sheet configurationPOST /api/admin/walk-sheet-config- Save walk sheet configuration
Troubleshooting¶
Common Issues¶
Locations not showing¶
- Verify table has required columns (
Geo-Location,latitude,longitude) - Check that coordinates are valid numbers
- Ensure API token has read permissions
- Verify
NOCODB_VIEW_URLis correct
Cannot add locations¶
- Verify API token has write permissions
- Check browser console for errors
- Ensure coordinates are within valid ranges
- Verify user is authenticated
Authentication issues¶
- Verify login table is properly configured
- Check that user email exists in Login table
- Ensure
NOCODB_LOGIN_SHEETURL is correct
Build script failures¶
- Check that
NOCODB_API_URLandNOCODB_API_TOKENare correct - Verify NocoDB instance is accessible
- Check network connectivity
- Review script output for specific error messages
Development Mode¶
For development and debugging:
This will start the application with hot reload and detailed logging.
Logs and Monitoring¶
View application logs:
Check health status:
Security Considerations¶
- API Token Security: Keep tokens secure and rotate regularly
- HTTPS: Use HTTPS in production
- CORS Configuration: Set appropriate
ALLOWED_ORIGINS - Cookie Security: Configure
COOKIE_DOMAINproperly - Input Validation: All inputs are validated server-side
- Rate Limiting: API endpoints have rate limiting
- Session Security: Use a strong
SESSION_SECRET
Maintenance¶
Regular Updates¶
# Stop the application
docker-compose down
# Pull updates (if using git)
git pull origin main
# Rebuild and restart
docker-compose build
docker-compose up -d
Backup Considerations¶
- NocoDB data is stored in your NocoDB instance
- Back up your
.envfile securely - Consider backing up QR code images from the Settings table
Performance Tips¶
- Monitor NocoDB performance and scaling
- Consider enabling caching for high-traffic deployments
- Use CDN for static assets if needed
- Monitor Docker container resource usage
Support¶
For issues or questions: 1. Check the troubleshooting section above 2. Review NocoDB documentation 3. Check Docker and Docker Compose documentation 4. Open an issue on GitHub