docs/docs/en/plugins/@nocobase/plugin-map/index.md
In NocoBase v2, the Map block displays geographic data from a collection on a map. It supports AMap and Google Maps, and can render point, line, polygon, and circle fields. You can also add actions to the block to open record views, filter data, refresh data, or run custom logic.
The Map block is a collection block. Before using it, enable @nocobase/plugin-map and create at least one map field in the target collection.
After enabling the plugin, go to "Plugin settings / Map manager" and configure the map provider.
The required settings are:
Access key, plus securityJsCode or serviceHostApi keyAfter saving the settings, map fields and map blocks load the provider selected by the field's map type. If the map cannot be loaded, check whether the key is valid, whether the domain whitelist includes the current domain, and whether the browser can access the selected map provider.
When adding a field to a collection, choose a field type from the "Map-based geometry" group.
| Field type | Usage |
|---|---|
| Point | Marks a single location, such as a store, device, or customer address |
| Line | Represents a route or track |
| Polygon | Represents an area |
| Circle | Represents a radius around a center point |
You need to choose the "Map type" when creating the field. This determines whether the field editor and the block use AMap or Google Maps. Usually, one business dataset should use one map type consistently.
In v2 page configuration mode, click "Add block" and choose "Map" from the "Data Blocks" group.
When creating the block, choose:
If the collection has no available map field, the Map field selector will be empty. Add a point, line, polygon, or circle field to the collection first.
After creating the block, you can adjust its display and interaction behavior from the block settings.
| Setting | Description |
|---|---|
| Map field and marker field | Changes the map field used by the block and the label field for point markers |
| Data scope | Limits the records loaded and displayed by the map block |
| Concatenation order field | Sorts point markers and connects them into a route. It only takes effect for point fields |
| Default zoom level | Sets the initial map zoom level |
| Actions | Adds buttons such as filter, add new, popup, link, refresh, custom request, AI employee, and JS action to the top of the block |
The Map block loads all records that match the data scope without pagination. For large datasets, configure a data scope or add filter actions to narrow the displayed records.
The Map block renders each record's map field as a map overlay. Clicking an overlay triggers the record opening flow, which is usually used to open a popup, drawer, or another record view.
The block provides selection tools in the upper-left corner:
Selected records are synced to the block resource and can be used by later block actions.
The v2 client implementation of the Map block is located in packages/plugins/@nocobase/plugin-map/src/client-v2/.
Key files:
plugin.tsx: registers map fields, the Map manager settings page, and v2 FlowModel loadersmodels/MapBlockModel.tsx: defines the map block model. It extends CollectionBlockModel and defines flows for block creation, data scope, sorting, zoom level, and opening recordsmodels/MapActionGroupModel.tsx: defines the actions available in the map blockmodels/MapBlockComponent.tsx: dispatches rendering to AMap or Google Maps according to the field's mapTypemodels/fieldModels/: contains v2 model implementations for point, line, polygon, and circle fieldsTo extend another map provider, usually add a new mapType option for map fields, then implement the corresponding map renderer and block component.