Skip to content

[Maps] MapEmbeddable setLayerList#52573

Merged
nreese merged 3 commits intoelastic:masterfrom
nreese:set_layer_list
Dec 11, 2019
Merged

[Maps] MapEmbeddable setLayerList#52573
nreese merged 3 commits intoelastic:masterfrom
nreese:set_layer_list

Conversation

@nreese
Copy link
Contributor

@nreese nreese commented Dec 9, 2019

Fixes #52504

Adds setLayerList method to MapEmbeddable so embeddable consumers can update geojson layers

const factory = new MapEmbeddableFactory();
const state = {
  layerList: [
    {
      'id': 'gaxya',
      'label': 'My geospatial data',
      'minZoom': 0,
      'maxZoom': 24,
      'alpha': 1,
      'sourceDescriptor': {
        'id': 'b7486',
        'type': 'GEOJSON_FILE',
        '__featureCollection': {
          "type": "FeatureCollection",
          "features": [
            {
              "type": "Feature",
              "geometry": {
                "type": "Polygon",
                "coordinates": [
                  [
                    [0, 0], [10, 10], [10, 0], [0, 0]
                  ]
                ]
              },
              "properties": {
                "name": "null island",
                "another_prop": "something else interesting"
              }
            }
          ]
        }
      },
      'visible': true,
      'style': {
        'type': 'VECTOR',
        'properties': {}
      },
      'type': 'VECTOR'
    }
  ],
  title: 'my map',
}
const input = {
  hideFilterActions: true,
  isLayerTOCOpen: false,
  openTOCDetails: ['tfi3f', 'edh66'],
  mapCenter: { lat: 0.0, lon: 0.0, zoom: 7 }
}
const mapEmbeddable = await factory.createFromState(state, input, parent);

mapEmbeddable.setLayerList([
  {
    'id': 'gaxya',
    'label': 'My geospatial data',
    'minZoom': 0,
    'maxZoom': 24,
    'alpha': 1,
    'sourceDescriptor': {
      'id': 'b7486',
      'type': 'GEOJSON_FILE',
      '__featureCollection': {
        "type": "FeatureCollection",
        "features": [
          {
            "type": "Feature",
            "geometry": {
              "type": "Polygon",
              "coordinates": [
                [
                  [35, 35], [45, 45], [45, 35], [35, 35]
                ]
              ]
            },
            "properties": {
              "name": "null island",
              "another_prop": "something else interesting"
            }
          }
        ]
      }
    },
    'visible': true,
    'style': {
      'type': 'VECTOR',
      'properties': {}
    },
    'type': 'VECTOR'
  }
]);

@nreese nreese added release_note:enhancement Team:Geo Former Team Label for Geo Team. Now use Team:Presentation v8.0.0 v7.6.0 labels Dec 9, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-gis (Team:Geo)

@shahzad31
Copy link
Contributor

Looks Good and full-fill the requirement. Can you also add the code to hide layer controls in this PR? I skipped that part in prev PR if you remember, i have had a change of heart and would like to have an option in case, WDYT? we can keep the attribute control.
We can also do a separate PR if you like.

image

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review

@nreese
Copy link
Contributor Author

nreese commented Dec 11, 2019

Can you also add the code to hide layer controls in this PR

I will create a separate PR to allow hiding the layer legend

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@nreese nreese merged commit 9c20361 into elastic:master Dec 11, 2019
nreese added a commit to nreese/kibana that referenced this pull request Dec 11, 2019
* [Maps] MapEmbeddable setLayerList

* review feedback
nreese added a commit that referenced this pull request Dec 11, 2019
* [Maps] MapEmbeddable setLayerList

* review feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:enhancement Team:Geo Former Team Label for Geo Team. Now use Team:Presentation v7.6.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Maps] Embeddable maps, allow updating layer data at runtime

4 participants