Map Styles
Customize the appearance of your maps with various styles in 3DMapFi.
3DMapFi provides a range of styles to customize the appearance of your maps, allowing you to create visually appealing and informative representations of geographic data. Styles include layers, sources, and expressions that can be applied to different map elements.
Available Styles
- Satellite: Aerial imagery with terrain and building details.
- Street: Standard road map with streets, labels, and points of interest.
- Dark: A dark-themed map suitable for night mode or low-light environments.
- Light: A light-themed map for a clean and modern look.
- Custom: Create your own style using 3DMapFi Editor or other tools.
Terrain Styles
3DMapFi also supports terrain-enhanced styles, allowing you to visualize elevation, hillshading, and 3D terrain features. These can be combined with any base style for a more immersive experience.
Applying Styles
You can apply styles to your map during initialization or dynamically at runtime. Here’s how to set a style when creating a new map:
You can also change the style of an existing map:
Switching Styles Dynamically
When switching styles at runtime, you may want to preserve certain layers or controls. Use event listeners to re-add custom layers or UI elements after the style loads.
Customizing Styles
You can customize existing styles or create new ones using the 3DMapFi Editor. This allows you to modify colors, fonts, and other visual elements to match your branding or design preferences.
Layer Types
- Fill: For polygons such as parks, lakes, or land use.
- Line: For roads, boundaries, and paths.
- Symbol: For icons and text labels.
- Raster: For satellite imagery or raster tiles.
- Circle: For point data visualizations.
- Hillshade: For terrain shading.
Expressions
Expressions allow you to create data-driven styles. For example, you can color roads based on traffic data or population density.
Style Editor
The Style Editor provides a user-friendly interface to create and modify map styles. You can:
- Add or remove layers
- Adjust layer properties (e.g., color, opacity, visibility)
- Create custom expressions for dynamic styling
- Save and export your styles for use in your applications For more details on using the Style Editor, refer to the Map Editor documentation.
Importing and Exporting Styles
You can import existing style JSON files into the Style Editor, or export your custom styles for use in other applications.
Example Style Configuration
Here’s an example of a custom style configuration using the Style Editor:
This configuration defines a simple style with a red road layer sourced from OpenStreetMap. You can expand this by adding more layers and customizing their properties.
Tips and Best Practices
- Performance: Limit the number of layers and sources for optimal performance.
- Branding: Use custom fonts and colors to align maps with your brand.
- Accessibility: Ensure sufficient contrast and readable labels for all users.
- Versioning: Keep track of style versions for easier maintenance and updates.
- Testing: Preview your styles on different devices and zoom levels.
Advanced Topics
Programmatic Style Manipulation
You can add, remove, or update layers and sources at runtime using the map API:
Using Third-Party Styles
3DMapFi is compatible with most map style specifications. You can use styles from third-party providers or open-source repositories by referencing their style URLs.
Using Tools
We provides tools to enhance your map styling experience: