map.create

Description

object map.create(object/array maps)

This method allows to create new maps.

This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

Parameters

(object/array) Maps to create.

Additionally to the standard map properties, the method accepts the following parameters.

ParameterTypeDescription
linksarrayMap links to be created on the map.
selementsarrayMap elements to be created on the map.
urlsarrayMap URLs to be created on the map.
usersarrayMap user shares to be created on the map.
userGroupsarrayMap user group shares to be created on the map.
shapesarrayMap shapes to be created on the map.
linesarrayMap lines to be created on the map.

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.

Return values

(object) Returns an object containing the IDs of the created maps under the sysmapids property. The order of the returned IDs matches the order of the passed maps.

Examples

Create an empty map

Create a map with no elements.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "map.create",
  4. "params": {
  5. "name": "Map",
  6. "width": 600,
  7. "height": 600
  8. },
  9. "id": 1
  10. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "sysmapids": [
  5. "8"
  6. ]
  7. },
  8. "id": 1
  9. }

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:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "map.create",
  4. "params": {
  5. "name": "Host map",
  6. "width": 600,
  7. "height": 600,
  8. "selements": [
  9. {
  10. "selementid": "1",
  11. "elements": [
  12. {"hostid": "1033"}
  13. ],
  14. "elementtype": 0,
  15. "iconid_off": "2"
  16. },
  17. {
  18. "selementid": "2",
  19. "elements": [
  20. {"hostid": "1037"}
  21. ],
  22. "elementtype": 0,
  23. "iconid_off": "2"
  24. }
  25. ],
  26. "links": [
  27. {
  28. "selementid1": "1",
  29. "selementid2": "2"
  30. }
  31. ]
  32. },
  33. "id": 1
  34. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "sysmapids": [
  5. "9"
  6. ]
  7. },
  8. "id": 1
  9. }

Create a trigger map

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

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "map.create",
  4. "params": {
  5. "name": "Trigger map",
  6. "width": 600,
  7. "height": 600,
  8. "selements": [
  9. {
  10. "elements": [
  11. {"triggerid": "12345"},
  12. {"triggerid": "67890"}
  13. ],
  14. "elementtype": 2,
  15. "iconid_off": "2"
  16. }
  17. ]
  18. },
  19. "id": 1
  20. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "sysmapids": [
  5. "10"
  6. ]
  7. },
  8. "id": 1
  9. }

Map sharing

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

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "map.create",
  4. "params": {
  5. "name": "Map sharing",
  6. "width": 600,
  7. "height": 600,
  8. "users": [
  9. {
  10. "userid": "4",
  11. "permission": "3"
  12. }
  13. ],
  14. "userGroups": [
  15. {
  16. "usrgrpid": "7",
  17. "permission": "2"
  18. }
  19. ]
  20. },
  21. "id": 1
  22. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "sysmapids": [
  5. "9"
  6. ]
  7. },
  8. "id": 1
  9. }

Map shapes

Create a map with map name title.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "map.create",
  4. "params": {
  5. "name": "Host map",
  6. "width": 600,
  7. "height": 600,
  8. "shapes": [
  9. {
  10. "type": 0,
  11. "x": 0,
  12. "y": 0,
  13. "width": 600,
  14. "height": 11,
  15. "text": "{MAP.NAME}"
  16. }
  17. ]
  18. },
  19. "id": 1
  20. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "sysmapids": [
  5. "10"
  6. ]
  7. },
  8. "id": 1
  9. }

Map lines

Create a map line.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "map.create",
  4. "params": {
  5. "name": "Map API lines",
  6. "width": 500,
  7. "height": 500,
  8. "lines": [
  9. {
  10. "x1": 30,
  11. "y1": 10,
  12. "x2": 100,
  13. "y2": 50,
  14. "line_type": 1,
  15. "line_width": 10,
  16. "line_color": "009900"
  17. }
  18. ]
  19. },
  20. "id": 1
  21. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "sysmapids": [
  5. "11"
  6. ]
  7. },
  8. "id": 1
  9. }

See also

Source

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