[英]Set D3 projection in Openlayers 4
I confused on D3 Integration using Openlayers 4. 我对使用Openlayers 4进行D3集成感到困惑。
The confused code is following : var d3Projection = d3.geo.mercator().scale(1).translate([0, 0]);
混乱的代码如下: var d3Projection = d3.geo.mercator().scale(1).translate([0, 0]);
Why set the value of ' scale ' is ' 1 ' and the ' translate ' is ' [0, 0] ' when init the Mercator projection 初始化墨卡托投影时,为什么将' scale '的值设置为' 1 '而' translate '的设置为[[0,0] '
They are set there so that the bounds of the features can be computed, and, followingly, the correct scale
and center
can be deduced. 在那里设置它们,以便可以计算特征的边界 ,然后可以推导出正确的scale
和center
。
Try putting an extra console.log(scale, center)
into the canvasFunction
, and then move the map, zoom it, or try emulating a high-DPI display (eg. in Chrome Developer Tools). 尝试将一个额外的console.log(scale, center)
放入canvasFunction
,然后移动地图,缩放地图或模拟高DPI显示(例如,在Chrome开发者工具中)。 You'll see how these values change with every pan and zoom. 您将看到这些值如何随每次平移和缩放而变化。
The values 1
and [0, 0]
are set to ease the computations, as defaults are set so that the whole Earth map would be drawn by default (per scale and translate documentation). 设置值1
和[0, 0]
是为了简化计算,因为设置了默认值,因此默认情况下将绘制整个地球地图(按比例和转换文档)。 That's practical for when you're coding the function for the first time and want to see some sane results, but less useful when you need to compute the projected bounds. 第一次使用该函数进行编码并希望看到一些合理的结果时,这很实用,但是当您需要计算投影范围时,它就没什么用了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.