Overlapped Maps
This example demonstrates how to layer multiple map views on top of each other, creating overlay effects.
Live Demo
Code Implementation
Setup UI and Container
First, create the app bar and main container to hold both maps:
Create Overlapped Maps
Create two map instances with different sizes and positions:
Key Features
Map Layering
Two independent GemMap instances are created using different view IDs:
- Background Map (view ID: 0): Full-screen map covering entire viewport
- Overlay Map (view ID: 1): Smaller map positioned in top-left corner (40% viewport width/height)
CSS Positioning
Maps are layered using CSS absolute positioning and z-index:
- Background:
z-index: 1, positioned attop: 0, left: 0with100%width/height - Overlay:
z-index: 2, positioned attop: 20px, left: 20pxwith40vw x 40vhsize
Independent Map Instances
Each map is completely independent:
- Separate GemMap instance with unique view ID
- Can have different center coordinates
- Can have different zoom levels
- Can display different map styles
- Can respond to gestures independently
Styling Details
The smaller overlay map includes visual enhancements:
- Border: 2px solid border (#222) for clear separation
- Border Radius: 10px rounded corners for modern appearance
- Box Shadow: Subtle shadow for depth effect
- Background: White background for clean overlay look
How It Works
- Initialize GemKit: Set up the SDK with API token
- Create Container: Main container positioned below app bar
- Create Background Map: Full-screen map using
gemKit.createView(0) - Create Overlay Map: Smaller map using
gemKit.createView(1)with different styling - Layer Maps: Use CSS z-index to control stacking order
Implementation Details
- View IDs: Each map requires a unique view ID (0 for background, 1 for overlay)
- Container Management: Each map has its own container div with specific styling
- Z-Index Hierarchy: Background map (z-index: 1) sits below overlay map (z-index: 2)
- Responsive Sizing: Overlay uses viewport units (40vw x 40vh) for responsive behavior
- Overflow Hidden: Prevents map content from extending beyond rounded corners
Use Cases
- Comparison Views: Compare two different map styles or time periods
- Picture-in-Picture: Show detailed view alongside overview map
- Split Context: Display different map data simultaneously
- Navigation Aid: Keep overview map visible while exploring details
- Multi-Region Monitoring: Monitor different geographic areas at once
Next Steps
- Multiview Map - Display multiple maps in grid layout
- Map Selection - Interact with layered maps