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

Image on a map: NaN width/height #6580

Closed
pixelspark opened this issue Jun 4, 2020 · 7 comments · Fixed by #7296
Closed

Image on a map: NaN width/height #6580

pixelspark opened this issue Jun 4, 2020 · 7 comments · Fixed by #7296
Labels
Area - Map Bug 🐛 P3 Should be fixed at some point

Comments

@pixelspark
Copy link

When creating a map using Vega-Lite and circle markers, all is well (very pretty!). After changing the marker type to "image", adding "width" and "height" values, as well as adding a "url" encoding, it appears the images that are put on the map do not receive proper width/height.

The same usage of images appears to work fine on regular (non-geo) charts. To reproduce, paste in the online editor:

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "layer": [
    {
      "mark": {
        "type": "geoshape",
        "fill": "#ddd",
        "stroke": "#fff",
        "strokeWidth": 1
      },
      "data": {
        "url": "data/us-10m.json",
        "format": {"type": "topojson", "feature": "states"}
      }
    },
   
    {
      "mark": {"type": "image", "width":10, "height":10},
      "data": {"url": "data/airports.csv"},
      "encoding": {
        "latitude": {"field": "latitude", "type": "quantitative"},
        "longitude": {"field": "longitude", "type": "quantitative"},
        "url": {"datum": "data/ffox.png", "type": "nominal"}
      }
    }
  ],
  "projection": {"type": "albersUsa"},
  "width": 900,
  "height": 500,
  "config": {"view": {"stroke": null}}
}

Result in (most recent) Chrome:

image

image

@domoritz
Copy link
Member

domoritz commented Jun 4, 2020

It looks like we don't support datum in latitude/longitude yet.

Screen Shot 2020-06-04 at 10 03 52

However, even if I modify the Vega spec manually (Open the Chart in the Vega Editor), I see NaN for width and height. This needs some more investigation.

@domoritz domoritz added the P3 Should be fixed at some point label Jun 4, 2020
@pixelspark
Copy link
Author

Hm, I believe the same problem still occurs when using field (this was my original use case but I had some other issues at the same time, so I am not totally sure).

Might it be that width/height are simply not converted the right way when a geographical projection is in place? Both should correspond to screen pixels, not degrees (at least that is how it works when used in non-geo markers)..

@domoritz
Copy link
Member

domoritz commented Jun 4, 2020

Yeah, something is going wrong here.

@domoritz
Copy link
Member

Maybe we introduced an issue in #5668.

domoritz added a commit that referenced this issue Mar 10, 2021
domoritz added a commit that referenced this issue Apr 8, 2021
@domoritz
Copy link
Member

domoritz commented Apr 8, 2021

image

@pixelspark
Copy link
Author

Awesome! 👍

Out of curiosity, now that this works: what extra changes would be needed to be able to plot tiles on the map? I assume width and height are now pixel-sized - or is it also possible to express these as (lon, lat) delta? Might as well add that if it is easy, as it would enable using e.g. OSM tiles.

@domoritz
Copy link
Member

domoritz commented Apr 8, 2021

I think you could do it (someone has done it for Vega already) but the performance isn't great for interactions. You can try it when we make a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area - Map Bug 🐛 P3 Should be fixed at some point
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants