[comment]: # translation:outdated

[comment]: # ({0067e4a0-0067e4a0})
# map.create

[comment]: # ({/0067e4a0-0067e4a0})

[comment]: # ({new-279559e4})
### Description

`object map.create(object/array maps)`

This method allows to create new maps.

::: noteclassic
This method is available to users of any type. Permissions
to call the method can be revoked in user role settings. See [User
roles](/manual/web_interface/frontend_sections/administration/user_roles)
for more information.
:::

[comment]: # ({/new-279559e4})

[comment]: # ({new-73d879ea})
### Parameters

`(object/array)` Maps to create.

Additionally to the [standard map properties](object#map), the method
accepts the following parameters.

|Parameter|[Type](/manual/api/reference_commentary#data_types)|Description|
|---------|---------------------------------------------------|-----------|
|links|array|Map [links](/manual/api/reference/map/object#map_link) to be created on the map.|
|selements|array|Map [elements](/manual/api/reference/map/object#map_element) to be created on the map.|
|urls|array|Map [URLs](/manual/api/reference/map/object#map_url) to be created on the map.|
|users|array|Map [user](/manual/api/reference/map/object#map_user) shares to be created on the map.|
|userGroups|array|Map [user group](/manual/api/reference/map/object#map_user_group) shares to be created on the map.|
|shapes|array|Map [shapes](/manual/api/reference/map/object#map_shapes) to be created on the map.|
|lines|array|Map [lines](/manual/api/reference/map/object#map_lines) to be created on the map.|

::: notetip
To create map links you'll need to set a map element
`selementid` to an arbitrary value and then use this value to reference
this element in the links `selementid1` or `selementid2` properties.
When the element is created, this value will be replaced with the
correct ID generated by Zabbix. [See
example.](create#create_a_host_map)
:::

[comment]: # ({/new-73d879ea})

[comment]: # ({2e617567-2e617567})
### Restituisce i valori

`(object)` Restituisce un oggetto contenente gli ID delle mappe create
sotto la proprietà `sysmapids`. L'ordine degli ID restituiti corrisponde all'ordine delle mappe passati.

[comment]: # ({/2e617567-2e617567})

[comment]: # ({b41637d2-b41637d2})
### Esempi

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({new-584ef8f6})
#### Create an empty map

Create a map with no elements.

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "map.create",
    "params": {
        "name": "Map",
        "width": 600,
        "height": 600
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "sysmapids": [
            "8"
        ]
    },
    "id": 1
}
```

[comment]: # ({/new-584ef8f6})

[comment]: # ({new-e32540ab})
#### Create a host map

Create a map with two host elements and a link between them. Note the
use of temporary "selementid1" and "selementid2" values in the map link
object to refer to map elements.

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "map.create",
    "params": {
        "name": "Host map",
        "width": 600,
        "height": 600,
        "selements": [
            {
                "selementid": "1",
                "elements": [
                    {"hostid": "1033"}
                ],
                "elementtype": 0,
                "iconid_off": "2"
            },

            {
                "selementid": "2",
                "elements": [
                    {"hostid": "1037"}
                ],
                "elementtype": 0,
                "iconid_off": "2"
            }
        ],
        "links": [
            {
                "selementid1": "1",
                "selementid2": "2"
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "sysmapids": [
            "9"
        ]
    },
    "id": 1
}
```

[comment]: # ({/new-e32540ab})

[comment]: # ({new-9a8ffa0d})
#### Create a trigger map

Create a map with trigger element, which contains two triggers.

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "map.create",
    "params": {
        "name": "Trigger map",
        "width": 600,
        "height": 600,
        "selements": [
            {
                "elements": [
                    {"triggerid": "12345"},
                    {"triggerid": "67890"}
                ],
                "elementtype": 2,
                "iconid_off": "2"
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "sysmapids": [
            "10"
        ]
    },
    "id": 1
}
```

[comment]: # ({/new-9a8ffa0d})

[comment]: # ({new-d8024143})
#### Map sharing

Create a map with two types of sharing (user and user group).

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "map.create",
    "params": {
        "name": "Map sharing",
        "width": 600,
        "height": 600,
        "users": [
            {
                "userid": "4",
                "permission": "3"
            }
        ],
        "userGroups": [
            {
                "usrgrpid": "7",
                "permission": "2"
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "sysmapids": [
            "9"
        ]
    },
    "id": 1
}
```

[comment]: # ({/new-d8024143})

[comment]: # ({new-2fa44a8b})
#### Map shapes

Create a map with map name title.

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "map.create",
    "params": {
        "name": "Host map",
        "width": 600,
        "height": 600,
        "shapes": [
            {
                "type": 0,
                "x": 0,
                "y": 0,
                "width": 600,
                "height": 11,
                "text": "{MAP.NAME}"
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "sysmapids": [
            "10"
        ]
    },
    "id": 1
}
```

[comment]: # ({/new-2fa44a8b})

[comment]: # ({new-5aa58242})
#### Map lines

Create a map line.

Request:

``` {.java}
{
    "jsonrpc": "2.0",
    "method": "map.create",
    "params": {
        "name": "Map API lines",
        "width": 500,
        "height": 500,
        "lines": [
            {
                "x1": 30,
                "y1": 10,
                "x2": 100,
                "y2": 50,
                "line_type": 1,
                "line_width": 10,
                "line_color": "009900"
            }
        ]
    },
    "auth": "038e1d7b1735c6a5436ee9eae095879e",
    "id": 1
}
```

Response:

``` {.java}
{
    "jsonrpc": "2.0",
    "result": {
        "sysmapids": [
            "11"
        ]
    },
    "id": 1
}
```

[comment]: # ({/new-5aa58242})

[comment]: # ({436079d5-436079d5})
### Guarda anche

-[Map element](object#map_element)
-[Map link](object#map_link)
-[Map URL](object#map_url)
-[Map user](object#map_user)
-[Map user group](object#map_user_group)
-[Map shape](object#map_shapes)
-[Map line](object#map_lines)

[comment]: # ({/436079d5-436079d5})

[comment]: # ({a9533b09-a9533b09})
### Fonte

CMap::create() in *ui/include/classes/api/services/CMap.php*.

[comment]: # ({/a9533b09-a9533b09})
