Skip to content

Legends

Richard Barad edited this page Jan 15, 2020 · 9 revisions

MapBuilder uses the following logic for legends:

  • If the layer is stored in the API, and a legend configuration is specified than the legend configuration will be pulled from the API. Using an API legend also allows for easy translation of the legends since text can be added in multiple languages.
  • If the layer has a "legendLayer": [0] the legend used will be pulled from the legend service. Typically, the legend service used is https://gis-gfw.wri.org/arcgis/rest/services/legends/MapServer. However, a user could create their own custom legend service to support layers without legends.
  • If the layer comes from a Feature Service or Map Service the legend for the service is used.
  • Layers which are included in the Webmap use the legend from the ArcGIS Online Webmap

The examples below show some samples of legend configurations supported by the API. The Legend configuration should be included in the API's legendConfig. Below are examples of supported legend types.

API Legends

Basic Legend - Squares as shown below.

Image of legend

{
		"name": {
			"ka": "GLAD შეტყობინებები",
			"zh": "GLAD 预警",
			"id": "Peringatan GLAD",
			"pt": "Alertas GLAD",
			"es": "Alertas GLAD",
			"fr": "Alertes GLAD",
			"en": "GLAD Alerts"
		},
		"type": "basic",
		"items": [{
				"outlineColor": "#555555",
				"color": "#DC6699",
				"name": {
					"ka": "GLAD შეტყობინებები",
					"zh": "GLAD 预警",
					"id": "Peringatan GLAD",
					"pt": "Alertas GLAD",
					"es": "Alertas GLAD",
					"fr": "Alertes GLAD",
					"en": "GLAD Alerts"
				}
			},
			{
				"outlineColor": "#555555",
				"color": "#e4c600",
				"name": {
					"ka": "ბოლო შეტყობინებები",
					"zh": "最近的提醒",
					"id": "Lansiran Terbaru",
					"pt": "Alertas Recentes",
					"es": "Alertas recientes",
					"fr": "Alertes récentes",
					"en": "Recent Alerts"
				}
			}
			]
	}

Line Legend

Line legend

{
        "type": "line",
        "name": {
          "zh": "Line Legend",
          "pt": "Line Legend",
          "ka": "Line Legend",
          "id": "Line Legend",
          "fr": "Line Legend",
          "es": "Line Legend",
          "en": "Line Legend"
        },
        "items": [
          {
            "thickness": "1",
            "name": {
              "zh": "Line 1",
              "pt": "Line 1",
              "ka": "Line 1",
              "id": "Line 1",
              "fr": "Line 1",
              "es": "Line 1",
              "en": "Line 1"
            },
            "lineType": "solid",
            "color": "#6A1ED2"
          },
          {
            "thickness": "2",
            "name": {
              "zh": "Line 2",
              "pt": "Line 2",
              "ka": "Line 2",
              "id": "Line 2",
              "fr": "Line 2",
              "es": "Line 2",
              "en": "Line 2"
            },
            "lineType": "dashed",
            "color": "#DC14DC"
          }
        ]
      }

Cloropleth Legend

Chloropleth Legend

{
		"items": [{
				"color": "#ffffb2",
				"name": {
					"en": "Step 1",
					"es": "Step 1",
					"fr": "Step 1",
					"id": "Step 1",
					"ka": "Step 1",
					"pt": "Step 1",
					"zh": "Step 1"
				}
			}, {
				"color": "#fecc5c",
				"name": {
					"en": "Step 2",
					"es": "Step 2",
					"fr": "Step 2",
					"id": "Step 2",
					"ka": "Step 2",
					"pt": "Step 2",
					"zh": "Step 2"
				}
			}, {
				"color": "#fd8d3c",
				"name": {
					"en": "Step 3",
					"es": "Step 3",
					"fr": "Step 3",
					"id": "Step 3",
					"ka": "Step 3",
					"pt": "Step 3",
					"zh": "Step 3"
				}
			}, {
				"color": "#f03b20",
				"name": {
					"en": "Step 4",
					"es": "Step 4",
					"fr": "Step 4",
					"id": "Step 4",
					"ka": "Step 4",
					"pt": "Step 4",
					"zh": "Step 4"
				}
			}, {
				"color": "#bd0026",
				"name": {
					"en": "Step 5",
					"es": "Step 5",
					"fr": "Step 5",
					"id": "Step 5",
					"ka": "Step 5",
					"pt": "Step 5",
					"zh": "Step 5"
				}
			}
		],
		"name": {
			"en": "Gradient Legend",
			"es": "Gradient Legend",
			"fr": "Gradient Legend",
			"id": "Gradient Legend",
			"ka": "Gradient Legend",
			"pt": "Gradient Legend",
			"zh": "Gradient Legend"
		},
		"type": "gradient"
	}