This is a template repository for creating Austin Digital Twin project pages. This template provides basic common page functionality (including HTML, JS, CSS) to help developers quickly start new projects and follow unified development standards.
AustinDigitalTwinPage-Template/
βββ index.html # Main HTML file
βββ assets/
β βββ css/
β β βββ style.css # Base styles (fonts, map, loading animation, etc.)
β β βββ projectMap.css # Project-specific styles (dropdown menu, custom controls, etc.)
β βββ js/
β β βββ map_common.js # Common map functionality (location, search, basic controls, etc.)
β β βββ project_map.js # Project-specific functionality (custom layers, data processing, etc.)
β β βββ map_init.js # Map initialization script
β βββ images/ # Image resources directory
β βββ fonts/ # Font files directory (if needed)
βββ data/ # Data files directory (optional)
βββ README.md # This file
Copy the entire AustinDigitalTwinPage-Template directory to your project location and rename it to your project name.
cp -r AustinDigitalTwinPage-Template YourProjectName
cd YourProjectName- Page Title and Metadata: Update the project name and description in
<title>and<meta>tags - Project Icon: Replace
assets/images/project_icon.pngwith your project icon - Modal Content: Update the content in the info modal (
infoModal) and credits modal (creditsModal) - Header Navigation: Modify the project title and color (default uses
#bf5700) - Layer Control Menu: Add or modify layer checkboxes in
filter-menuaccording to your project needs
- Map Center and Zoom Level: Modify the
centerandzoomparameters in theinitMap()function - API Keys: Add your API key if you need to use Esri geocoding search
- Data Loading: Uncomment and modify the
loadProjectData()call to point to your data file
- Layer Functions: Implement
buildLayer1(),buildLayer2(), etc. functions according to your project needs - Event Bindings: In the
buildDropdownMenu()function, bind your checkboxes to corresponding layer functions - Data Processing: Implement the
loadProjectData()function to load and process your data
- Images: Place project icons, favicon, etc. in the
assets/images/directory - Data: Place JSON, GeoJSON, and other data files in the
data/directory (if needed) - Fonts: If you need to use ManifoldDSA or FontAwesome fonts, place font files in the
assets/fonts/directory
Test your project on a local server, and after ensuring all features work correctly, deploy to the server.
Main HTML file containing:
- Standard HTML5 structure
- Leaflet map library and related plugin references
- Bootstrap modals (info and credits)
- Header navigation bar (project title, icon, Urban Info Lab link)
- Layer control dropdown menu
- Usage instructions modal
- JavaScript file references (loaded in order)
Base styles file containing:
- Font definitions (ManifoldDSA, FontAwesome)
- Global styles (body, links, etc.)
- Map container styles
- Loading animation (spinner)
- Marker cluster styles
Project-specific styles containing:
- Dropdown menu styles
- Custom control styles
- Loading overlay styles (optional)
- Project-specific custom styles
Common map functionality module containing:
- User Location Functionality:
getUserLocation(),onLocationFound(), etc. - Map Basic Functionality:
initMap(),addMapLayer(), etc. - Geocoding Search:
initGeocodingSearch()(requires Esri API key) - Custom Controls:
createCustomControl(),createLocationButton(), etc. - Dropdown Menu Framework:
buildDropdownMenuBase()(base framework, requires project-specific event bindings) - Utility Functions:
hideSpinner(),setupMapClickHandler(), etc.
Note: Functions in this file are generic and can be used directly, but some functions may need configuration according to project requirements (such as map center point, API keys, etc.).
Project-specific functionality module containing:
- Layer Management:
buildLayer1(),removeLayer1(), etc. functions for creating and managing project-specific map layers - Dropdown Menu Event Bindings:
buildDropdownMenu()function that binds checkboxes to layer functions - Data Loading:
loadProjectData()function for loading data from files or APIs - Default Layer Initialization:
initDefaultLayers()function that sets up default layers to display on page load - Custom Controls:
createProjectControls()function for creating project-specific control buttons
Note: This file requires extensive customization based on your project needs.
Map initialization script containing:
- Main Initialization Function:
initMapAndFeatures(), which initializes all features in sequence - Page Load Handling: Ensures map initialization after DOM is loaded
Note: You may need to adjust the initialization order or add additional initialization steps according to your project requirements.
- File Separation: Keep HTML, CSS, and JavaScript files separate, avoid inlining large amounts of code
- Modularity: Put common functionality in
map_common.js, project-specific functionality inproject_map.js - Comments: Add JSDoc-style comments to functions, explaining parameters and return values
- Naming: Use meaningful variable and function names, follow camelCase naming convention
- Colors: Project primary color uses
#bf5700(UT Austin orange), can be adjusted according to project needs - Fonts: Use ManifoldDSA font as the primary font
- Responsive: Ensure the page displays correctly at different screen sizes
- Map Initialization: Always manage initialization flow uniformly in
map_init.js - Layer Management: Use the
projectLayersobject to manage all layers uniformly for easy addition and removal - Error Handling: Add appropriate error handling in data loading and API calls
- Performance Optimization: For large amounts of data points, use marker clustering (MarkerCluster) or chunked loading
- Data Format: Prefer GeoJSON format for storing geographic data
- Data Loading: Use
fetch()API for asynchronous data loading - Data Validation: Validate data format and integrity after loading data
- Create
buildLayerX()andremoveLayerX()functions inproject_map.js - Add corresponding properties to the
projectLayersobject - Bind checkbox events in
buildDropdownMenu() - Add checkboxes to the layer control menu in
index.html
- Use
createCustomControl()inproject_map.jsto create controls - Add controls to the map in
initMapAndFeatures()inmap_init.js
Modify the base map URL in the addMapLayer() function in map_common.js, or uncomment other base map options.
- The HTML structure for
data-loading-overlayalready exists inindex.html - Update the progress bar and percentage in the data loading function
- Hide the overlay after loading is complete
- API Keys: If using Esri geocoding or Google Maps, you need to add the corresponding API keys
- Cross-Origin Issues: If loading data from different domains, ensure the server has correct CORS headers set
- Browser Compatibility: The template uses modern JavaScript features, recommend using modern browsers
- Performance: For large amounts of data, consider using data pagination or virtual scrolling
If you encounter problems or need help:
- Refer to existing Austin Digital Twin projects (AustinSocialTwin, AustinUrbanMobility, AustinUrbanNoise, AustinCrime)
- Check Leaflet official documentation: https://leafletjs.com/
- Contact the Urban Info Lab team