A web application built with MapLibre GL JS that displays an interactive map of the United States with bounding box drawing functionality.
- Interactive US Map: Shows a detailed map focused on Champaign, Illinois area with streets, cities, and geographic information
- Navigation Controls: Zoom in/out, pan, and navigate the map
- Bounding Box Drawing: Draw rectangular bounding boxes on the map
- Coordinate Display: View the coordinates of all four corners of the bounding box
- Mobile Support: Works on both desktop and mobile devices
From the command prompt at C:\workspace-ywkim\bounding-box-on-the-map:
Option 1: Direct Browser Opening (Windows - Recommended)
start index.htmlOption 2: Using Python HTTP Server (if Python is installed)
python -m http.server 8000Then open your browser and go to: http://localhost:8000
Option 3: Using Node.js http-server (if Node.js is installed)
npx http-server -p 8000Then open your browser and go to: http://localhost:8000
Option 4: Using PHP (if PHP is installed)
php -S localhost:8000Then open your browser and go to: http://localhost:8000
- Navigate the Map:
- Use mouse wheel to zoom in/out
- Click and drag to pan around the map
- Use the navigation controls in the top-right corner
- Draw a Bounding Box:
- Check the "Bounding Box" checkbox in the top-left control panel
- Click and drag on the map to draw a rectangular bounding box
- The bounding box will appear in red color
- View Coordinates: After drawing a bounding box, the coordinates of all four corners will be displayed in the control panel
- Dataset Creation: A confirmation dialog will appear asking if you want to create a dataset with the drawn bounding box
- API Integration: If confirmed, the application sends the coordinates to the building inventory API
- Map Engine: MapLibre GL JS (open-source alternative to Mapbox GL JS)
- Map Style: CartoDB Positron (clean, detailed map with street information)
- Bounding Box Color: Red (#ff0000) with 80% opacity for borders and 10% opacity for fill
- Coordinate Format: Decimal degrees with 6 decimal places precision
bounding-box-on-the-map/
├── index.html # Main HTML file with UI structure
├── script.js # JavaScript functionality for map and bounding box
└── README.md # This documentation file
This application works in all modern browsers that support WebGL:
- Chrome (recommended)
- Firefox
- Safari
- Edge
The application uses CDN-hosted MapLibre GL JS library, so no local installation is required. All dependencies are loaded automatically when you open the HTML file.
The application automatically sends bounding box coordinates to the building inventory API when a bounding box is drawn. To configure the API:
- Update Authorization Token: In
script.js, replace'bearer with token'with your actual authorization token on line 295 - API Endpoint: The default endpoint is
https://tools.in-core.org/data/api/datasets/tools/bldg-inventory - Bounding Box Format: Coordinates are sent as
[minLat, minLng, maxLat, maxLng]format
Note: Due to CORS (Cross-Origin Resource Sharing) policies, the API calls may be blocked when running the application from a local file (file:// protocol). This is a browser security feature. The application will show a user-friendly error message when this occurs.
To avoid CORS issues, run the application using one of the HTTP server options listed in the "Starting the Application" section above.
You can customize the application by modifying:
- Map style URL in
script.js(line 3) - Map center coordinates and zoom level in
script.js(lines 4-6) - Currently set to Champaign, Illinois - Bounding box color in
script.js(lines 175 and 185) - API endpoint and authorization in
script.js(lines 295-296) - UI styling in the
<style>section ofindex.html