Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vega] user should be able to set a specific tilemap service using the mapStyle property #88440

Merged
merged 9 commits into from
Feb 9, 2021

Conversation

alexwizp
Copy link
Contributor

@alexwizp alexwizp commented Jan 15, 2021

Summary

This is a PR continued discussion of the next comment

to discuss: in accordance with the following documentation https://www.elastic.co/guide/en/kibana/6.8/vega-with-a-map.html mapStyle param accepts just a 2 values: false and default.

It looks a little odd to me because in some cases it might be useful to let the user set a specific tms layer value. For example, if I set map.tilemap.url param and want to create some vis with that layer and some with the default one (road_map)

{
  $schema: https://vega.github.io/schema/vega/v5.json
  config: {
    kibana: {
      type: map
      mapStyle: road_map
    }
  }
}

To add support of that we just need to remove the following if statement from vis_type_vega/public/data_model/vega_parser.ts

if (res.mapStyle !== `default` && res.mapStyle !== false) {
    this._onWarning(
      i18n.translate('visTypeVega.vegaParser.mapStyleValueTypeWarningMessage', {
        defaultMessage:
          '{mapStyleConfigName} may either be {mapStyleConfigFirstAllowedValue} or {mapStyleConfigSecondAllowedValue}',
        values: {
          mapStyleConfigName: 'config.kibana.mapStyle',
          mapStyleConfigFirstAllowedValue: 'false',
          mapStyleConfigSecondAllowedValue: '"default"',
        },
      })
    );
    res.mapStyle = `default`;
  }

@nreese @thomasneirynck from your point of view should we support that case or not?

Originally posted by @alexwizp in #88316 (comment)

For people who will check these changes:

To test that changes please follow next steps:

  1. Start your Kibana instance with the following configuration property:
    map.tilemap.url: http://c.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg
  2. Create or open Vega visualizations with configured Map layer.
    You can use the following spec for testing:
{
  $schema: https://vega.github.io/schema/vega/v5.json
  config: {
    kibana: {
      type: map
    }
  }
}
  1. Apply changes and see which tile map layer was applied.
    Expected screen:
    image

  2. Set mapStyle option to false
    Expected screen:
    image

  3. Set emsTileServiceId option to dark_map. It's one of our default layers. Be sure that map.includeElasticMapsService configuration property is true
    Expected screen:
    image

@alexwizp alexwizp marked this pull request as ready for review January 18, 2021 16:19
@alexwizp alexwizp requested a review from a team January 18, 2021 16:19
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@alexwizp
Copy link
Contributor Author

@elasticmachine merge upstream

1 similar comment
@alexwizp
Copy link
Contributor Author

@elasticmachine merge upstream

// Can be set to one of the following:
// - set to false to disable base layer;
// - set to "default" to use Kibana's default base map layer;
// - set "mapStyle" to any Elastic Maps Service (EMS) tile layer id.
Copy link
Contributor

Choose a reason for hiding this comment

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

How about listing out valid tile layer ids here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we cannot guarantee that this doc will be updated on updating available EMS layers =)

Copy link
Contributor

@nreese nreese Jan 19, 2021

Choose a reason for hiding this comment

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

I think that is OK, and we can remove once elastic/ems-landing-page#304 is fixed and there is an easy way for users to get the ids from EMS. I will add a comment in elastic/ems-landing-page#304 to update these docs to link to available EMS baselayer ids once they are available.

Comment elastic/ems-landing-page#304 (comment)

Copy link
Contributor Author

@alexwizp alexwizp Jan 20, 2021

Choose a reason for hiding this comment

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

I'm still not a big fan of hard coding that id's. I see that currently for some reasons maps_legacy/ServiceSettings returns only road_map and in case if user set the value of map.tilemap.url I also see TMS in config/kibana.yml in that array:

image

I prefer to keep this message as it for now. But in parallel we are working on migration leaflet -> mapbox #88605 where we use @elastic/ems-client directly. So very soon "road_map_desaturated" and "dark_map" will be also available.

The goal of that PR is to remove wrong if statement from vega_parser.ts.

defaultMessage: '{mapStyleParam} was not found',
values: { mapStyleParam: `"mapStyle":${mapStyle}` },
defaultMessage:
'{mapStyleParam} was not found. Set to "default" to use Kibana\'s default base map layer or set to "false" to disable base layer',
Copy link
Contributor

Choose a reason for hiding this comment

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

How about listing out EMS layer ids when EMS is enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can do it, but from the other hand I don't like how our current vega warning messages looks like. It's just a text without any formatting. I would not like to overload these messages with this information. But if you insist I'll do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

far enough, maybe just putting the EMS ids in the docs then

@alexwizp
Copy link
Contributor Author

@elasticmachine merge upstream

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.

hi @alexwizp

I agree that it would be useful for Vega-users to set custom baselayers (either with map.tilemap.url or by explicitly setting the EMS-layer).

I'm not sure if I'm in favor of overloading the mapStyle parameter to this extent.


  1. `it overloads the mapStyle parameter to now expect three types
  • boolean false
  • string default
  • layer-id (which is an enumeration published by EMS)

The end-user behavior in the context of Kibana would end up being quite complicated:

mapStyle no map.tilemap.url map.tilemap.url: foobar/{x}/{y}/{z}
false .no basemap no basemap
undefined auto-switch road_map/dark_theme from EMS use foobar/{x}/{y}/{z}
default auto-switch road_map/dark_theme from EMS use foobar/{x}/{y}/{z}
ems layerId enumeration use the EMS layerId use the EMS layerId
  1. Overloading mapStyle puts implicit constraints on EMS

This change puts a constraint on EMS. EMS can not introduce a layer called default. Minor, but it is contextual knowledge we then need to maintain going forward.


Rather, my 2c would be to keep this change more minimal.

  1. Is it possible to start with improving the behavior of default?

This would just take into account whether maps.tilemap.url is set. This would align the behavior of Vega with how it is in the Maps-app or in the region and tile-map visualizations.

  1. To introduce the ability to set the EMS layerId, I would do this by adding a new parameter, instead of overloading the mapStyle value.

For example something like:

mapStyle: default
mapStyle: false
mapStyle: ems
emsTileLayerId: dark_theme

For (2), we should start taking into account whether connection to EMS has is been turned off explicitly. Once the mapbox-migration is complete, we can also will need to check whether the on-=rem setup is correct and the license is valid. This then can be surfaced into the warning message.


I think (1) would be a good first step, but for (2), I would wait until the mapbox-migration is complete. Given all the little edge-cases that (2) might introduce, it's probably something Maps-team should take on as well.


thanks, let me know what you think.

@alexwizp
Copy link
Contributor Author

@thomasneirynck from my perspective mapStyle option should accept only false to disable base layer and EMS layerId's. I don't see a lot of sense in default value. It works absolutely the same if we don't pass a value at all.

If we remove default then it doesn't seem to me that this property is overloaded

And I agree with you, let's get back to this PR after we finish with #88605.

@alexwizp
Copy link
Contributor Author

alexwizp commented Feb 2, 2021

@elasticmachine merge upstream

@alexwizp
Copy link
Contributor Author

alexwizp commented Feb 4, 2021

@elasticmachine merge upstream

@alexwizp
Copy link
Contributor Author

alexwizp commented Feb 4, 2021

PR updated as recommended by @thomasneirynck

@alexwizp
Copy link
Contributor Author

alexwizp commented Feb 5, 2021

@elasticmachine merge upstream

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

It works fine and the code is LGTM, my only concern is that is it a breaking change. Not a huge one but the users that have the mapStyle on default should change it to true. Otherwise they will see an error on the vega maps. So maybe a migration script could be a good solution here? Of course, the vega maps are on experimental phase so we could omit this. I would love your feedback on that @thomasneirynck @nreese

@nreese
Copy link
Contributor

nreese commented Feb 5, 2021

It works fine and the code is LGTM, my only concern is that is it a breaking change. Not a huge one but the users that have the mapStyle on default should change it to true. Otherwise they will see an error on the vega maps. So maybe a migration script could be a good solution here? Of course, the vega maps are on experimental phase so we could omit this. I would love your feedback on that @thomasneirynck @nreese

If its possible to write a migration script, then this PR should add one. We should strive to make upgrading between minors as seamless as possible.

@stratoula
Copy link
Contributor

I think we can, @alexwizp do you want to also take care of this?

@thomasneirynck
Copy link
Contributor

+1 on migration script, but imho I think the breaking change is fairly minor, and given that this is an experimental feature, it's imho something we could live with.

We can also remove default from the documentation (like in this PR), and log a deprecation warning when it is being used (defaulting to true then).

I don't feel strongly either way.

@alexwizp
Copy link
Contributor Author

alexwizp commented Feb 8, 2021

@elasticmachine merge upstream

@alexwizp
Copy link
Contributor Author

alexwizp commented Feb 8, 2021

@stratoula @thomasneirynck Let me clarify a little. Currently if user set value for mapStype to 'default' all works as before + we show the warning message.
image

I'm not a big fan of creating a migration script for that. I see some difficulties on JSON cause on parse/stringify specs with the 'default' value we lose user comment and formatting. Probably we can replace value using the regular string functions. But not sure if it's worth it....

@stratoula
Copy link
Contributor

This means, that the map will load, right? And the user will see a warning. Ok I am fine with it if the map team agrees 🙂

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.

thx @alexwizp. This is a nice addition, and thanks a lot for the API cleanup.

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

LGTM 👏

# Conflicts:
#	src/plugins/vis_type_vega/public/vega_view/vega_map_view/view.ts
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
visTypeVega 2.7MB 2.7MB -309.0B

History

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

@alexwizp alexwizp merged commit 19543d8 into elastic:master Feb 9, 2021
alexwizp added a commit to alexwizp/kibana that referenced this pull request Feb 9, 2021
…e mapStyle property (elastic#88440)

* [Vega] user should be able to set a specific tilemap service using the mapStyle property

* Update vega-reference.asciidoc

* fix PR comments

* rename mapStyle -> emsTileServiceId

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
jloleysens added a commit to jloleysens/kibana that referenced this pull request Feb 9, 2021
…timeline-and-rollover-info

* 'master' of github.com:elastic/kibana: (47 commits)
  [Fleet] Use TS project references (elastic#87574)
  before/beforeEach clean up (elastic#90663)
  [Vega] user should be able to set a specific tilemap service using the mapStyle property (elastic#88440)
  [Security Solution][Case] ServiceNow SIR Connector (elastic#88655)
  [Search Sessions] Enable extend from management (elastic#90558)
  [ILM] Delete phase redesign (rework) (elastic#90291)
  [APM-UI][E2E] use withGithubStatus step (elastic#90651)
  Add folding in kb-monaco and update some viewers (elastic#90152)
  [Grok Debugger] Changed test to wait for grok debugger container to exist to fix test flakiness (elastic#90543)
  Strongly typed EUI theme for styled-components (elastic#90106)
  Fix vega renovate label (elastic#90591)
  [Uptime] Migrate to TypeScript project references (elastic#90510)
  [Monitoring] Migrate data source for legacy alerts to monitoring data directly (elastic#87377)
  [Upgrade Assistant] Add A11y Tests (elastic#90265)
  [Time to Visualize] Adds functional tests for linking/unlinking panel from embeddable library (elastic#89612)
  [dev-utils/ship-ci-stats] fail when CI stats is down (elastic#90678)
  chore(NA): remove write permissions on Bazel remote cache for PRs (elastic#90652)
  chore(NA): move bazel workspace status from bash script into nodejs executable (elastic#90560)
  Use default ES distribution for functional tests (elastic#88737)
  [Alerts] Jira: Disallow labels with spaces (elastic#90548)
  ...

# Conflicts:
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/lib/absolute_timing_to_relative_timing.test.ts
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/lib/absolute_timing_to_relative_timing.ts
alexwizp added a commit that referenced this pull request Feb 9, 2021
…e mapStyle property (#88440) (#90745)

* [Vega] user should be able to set a specific tilemap service using the mapStyle property

* Update vega-reference.asciidoc

* fix PR comments

* rename mapStyle -> emsTileServiceId

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Vega Vega visualizations release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants