简体   繁体   中英

how can I zoom into a map using vega-lite?

I'm rendering some data onto a map using vega-lite. Currently, I have this schema, which renders the attached image:

{
  "title": "What's the nearest city to you?",
  "data": {
    "values": "...",
    "format": {
      "type": "csv"
    }
  },
  "encoding": {},
  "projection": {
    "type": "mercator"
  },
  "layer": [
    {
      "data": {
        "values": "...",
        "format": {
          "type": "topojson",
          "feature": "world-borders"
        }
      },
      "mark": {
        "type": "geoshape",
        "fill": "lightgrey",
        "stroke": "darkgrey"
      },
      "width": 800,
      "height": 600
    },
    {
      "mark": {
        "type": "circle",
        "size": 50
      },
      "encoding": {
        "latitude": {
          "field": "latitude",
          "type": "quantitative"
        },
        "longitude": {
          "field": "longitude",
          "type": "quantitative"
        },
        "color": {
          "field": "count",
          "type": "quantitative",
          "scale": {
            "range": [ "#f0f921", "#fcce25", "#fca636", "#f2844b", "#e16462", "#cc4778", "#b12a90", "#8f0da4", "#6a00a8", "#41049d", "#0d0887" ]
          }
        },
        "size": {
          "field": "count",
          "type": "quantitative"
        }
      }
    }
  ]
}

此架构的渲染视图

Now this looks pretty nice overall! I'm happy with it! But I would really like to be able to provide a rendered image zoomed into the densest areas of data, specifically Europe and the continental US. I've tried everything I can think of as specified in the vega and vega-lite documentation to no avail (all the properties I try have been weird—like rendering all the circles at a single pixel or just clipping the map.)

What I'd really like is just a way to say "show me a view of data+map between lat°long° and lat°long°", but nothing jumps out at me as being designed for that purpose. How can I do this?

In the current Vega-Lite release, panning and zooming are not available for geographic projections. See https://github.com/vega/vega-lite/issues/3306 for more details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM