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 Maps Referencing from kibana.yml #88316

Merged
merged 3 commits into from
Jan 15, 2021
Merged

Conversation

alexwizp
Copy link
Contributor

@alexwizp alexwizp commented Jan 14, 2021

Closes: #87853

Summary

"Vega maps should use map.tilemap.url when provided instead of getting its base map layer from Elastic map service"

Steps to reproduce:

  1. Change map.tilemap.url from default to point to another map tile service, like Openmaptiles.

  2. Open Vega in kibana and attempt to layer a map using the help guide found at https://www.elastic.co/guide/en/kibana/6.8/vega-with-a-map.html

For testing:

  1. set the following env params for your Kibana instance (you can do it in config/kibana.yml)
    map.tilemap.url: http://c.tile.stamen.com/watercolor/{z}/{x}/{y}.jpg
  2. open Kibana instance and create/open Vega visualization with Map layer. You can use the following empty vega spec for testing
 {
  $schema: https://vega.github.io/schema/vega/v5.json
  config: {
    kibana: {
      type: map
    }
  }
}
  1. After updating visualization your should see user configured map layer

image

  1. Also using"mapStyle": falseuser should be able to disable base layer.
{
  $schema: https://vega.github.io/schema/vega/v5.json
  config: {
    kibana: {
      type: map
      mapStyle: false
    }
  }
}

image

Comment on lines -51 to -58
if (!baseMapOpts) {
this.onWarn(
i18n.translate('visTypeVega.mapView.mapStyleNotFoundWarningMessage', {
defaultMessage: '{mapStyleParam} was not found',
values: { mapStyleParam: `"mapStyle": ${JSON.stringify(mapStyle)}` },
})
);
} else {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

impossible case. for all cases if (!baseMapOpts) { returns false

Copy link
Contributor

@nreese nreese Jan 14, 2021

Choose a reason for hiding this comment

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

Agreed that this logic is an impossible case (which is causing a bug), but a warning should be logged if const mapOptions = tmsServices.find((s) => s.id === mapStyle); returns undefined.

To view the issue, add map.includeElasticMapsService: false to your kibana.dev.yml. Then remove map.tilemap.url as well. This will disable EMS so mapOptions will be undefined. Then, running vega will fail because baseMapOpts is not properly defined
Screen Shot 2021-01-14 at 7 12 07 AM

I would recommend returning null from getMapStyleOptions if mapOptions is undefined. Then, add logic to the caller of getMapStyleOptions to check for null and log the warning if the return is null.

I am ok if you do not want to fix this issue in this PR, instead, we can just create a new issue and tackle this in a separate thread.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

was fixed it that PR

@alexwizp alexwizp self-assigned this Jan 14, 2021
@alexwizp alexwizp added v7.12.0 v8.0.0 Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Vega Vega visualizations release_note:fix labels Jan 14, 2021

let mapStyle;

if (mapConfig.mapStyle !== 'default') {
Copy link
Contributor Author

@alexwizp alexwizp Jan 14, 2021

Choose a reason for hiding this comment

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

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the idea of allowing users to specify which base layer to use. I think this would be best completed in a separate PR so the implementation can be discussed outside of the context of this fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree, it will be done out of that PR, just wanted to discuss it firstly

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

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

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for fixing this issue.
code review, tested in chrome

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
mapsLegacy 183 184 +1

Async chunks

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

id before after diff
mapsLegacy 721.7KB 721.7KB -76.0B
visTypeVega 1.5MB 1.5MB +736.0B
total +660.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
mapsLegacy 88.9KB 89.4KB +509.0B
visTypeVega 60.7KB 60.6KB -63.0B
total +446.0B

History

To update your PR or re-run it, just comment with:
@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.

LGTM, tested in Safari. Works as expected 🙂

@alexwizp alexwizp merged commit bc0368f into elastic:master Jan 15, 2021
alexwizp added a commit to alexwizp/kibana that referenced this pull request Jan 15, 2021
* Vega Maps Referencing from kibana.yml

Closes: elastic#87853

* update translations

* fix PR comments
alexwizp added a commit that referenced this pull request Jan 15, 2021
* Vega Maps Referencing from kibana.yml

Closes: #87853

* update translations

* fix PR comments
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:fix 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.

Vega Maps Referencing from kibana.yml
5 participants