如何使用vega-lite放大地图?

时间:2018-11-25 20:06:55

标签: vega-lite

我正在使用vega-lite将一些数据渲染到地图上。目前,我有以下架构,该架构呈现了附件图像:

{
  "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"
        }
      }
    }
  ]
}

the rendered view of this schema

现在整体看起来不错!我很高兴!但我真的很希望能够提供放大到最密集数据区域(尤其是欧洲和美国大陆)的渲染图像。我已经尝试了在vega和vega-lite文档中指定的所有我想不到的东西(我尝试的所有属性都很奇怪-例如将所有圆圈渲染为单个像素或仅剪切地图)。

我真正想要的只是说“向我展示纬度和纬度之间的数据和地图视图”的一种方式,但是为这个目的而设计的过程并没有让我惊讶。我该怎么办?

1 个答案:

答案 0 :(得分:0)

在当前的Vega-Lite版本中,平移和缩放不适用于地理投影。有关更多详细信息,请参见https://github.com/vega/vega-lite/issues/3306