问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/53471426/how-can-i-zoom-into-a-map-using-vega-lite