作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在用 d3 学习 topojson。
我有正确呈现的土地坐标信息。
那么,如何为海洋(基本上在陆地之外)添加颜色?我尝试为刻度着色,但没有填满整个 map 并留下空白点。
可视化托管于 http://jbk1109.github.io/
var projection = d3.geo.stereographic()
.scale(245)
.translate([width / 2, height / 2])
.rotate([-20, 0])
.clipAngle(180 - 1e-4)
.clipExtent([[0, 0], [width, height]])
.precision(.1);
var path = d3.geo.path()
.projection(projection)
var graticule = d3.geo.graticule();
var g = svg.append("g")
svg.append("path")
.datum(graticule)
.attr("class", "graticule")
.attr("d", path)
.style("fill","none")
.style("stroke","#777")
.style("stroke-width",0.2)
var land = svg.insert("path", ".graticule")
.datum(topojson.feature(world, world.objects.land))
.attr("class", "land")
.attr("d", path)
.style("fill",'#cbcbcb')
.style("opacity",0.8)
最佳答案
没有必要(而且在计算上会非常困难且有些昂贵)计算出陆地的倒数。但是您可以只为背景着色。
即您可以使用 CSS:
svg {
background: lightBlue;
}
<rect>
map 后面带有蓝色填充的元素:
svg.append('rect')
.attr('width', mapWidth)
.attr('height', mapHeight)
.attr('fill', 'lightBlue')
关于d3.js - 当我有陆地坐标信息时,如何在 d3 中使用 topojson 为海洋着色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26663982/
大家好:这对我来说仍然是个谜。在我按下“查找我”按钮后,我的应用加载蓝屏(海洋),其中包含以下内容: -(IBAction)findMe { self.mapView.showsUserLocat
我在 iOS (Swift) 上使用 Mapbox 的地理编码 API 来反转地理编码坐标。我已经能够使其适用于任何陆地坐标,但是在海洋上时我的代码无法运行(或打印地标): let t
我知道我可以在网页中添加 OpenStreetMap 或 Google map 作为 basemap 。但是,我正在寻找可以增强海洋效果的 basemap 。是否可以将 Esri 海洋 basemap
我是一名优秀的程序员,十分优秀!