【发布时间】:2021-09-02 22:03:53
【问题描述】:
尝试解决此问题,更改了 geoJsonURL 以接收更复杂的形状。使用这种新形状,缩放方法有效,但形状完全混乱。根据Coordinate system: WGS 84 (EPSG:4326) 和this stack topic,它应该或多或少像我现在必须计算正确的投影。但是,仍然给出了一个奇怪的路径输出。 非常感谢您的帮助,在此先感谢。
下面是原始主题,上面是新部分
我试图放大路径,但缩放方法不是 什么也不做。在一些主题中看到了 pointRadius 的使用 方法但不起作用。如果您注意到,路径几乎在中间 (我手动翻译),但很小。我做错了什么 我的方法?
我可以得到坐标系和盒子坐标(这不是 在本例中)以备不时之需。我一直在读一些 示例,但似乎没有任何效果。知道我在做什么 错误的 ?坐标系:WGS 84 (EPSG:4326)
提前致谢
/* geometryType=esriGeometryPolyline OR esriGeometryMultipoint OR esriGeometryPolygon OR esriGeometryEnvelope*/
const geoJsonURL = "https://sig.cm-figfoz.pt/arcgis/rest/services/Internet/MunisigWeb_DadosContexto/MapServer/2/query?f=geojson&where=(LOWER(NOME)%20LIKE%20LOWER(%27%25Alhadas%25%27))&returnGeometry=true&geometryType=esriGeometryPolyline&spatialRel=esriSpatialRelIntersects&outFields=*&outSR=3763"
const canvas = d3.select("#map").append("svg")
.attr("width", 500)
.attr("height", 500)
.style("border", "2px solid red");
const projection = d3.geoTransverseMercator()
.rotate([8.1331, 0])
.center([0, 39.6682])
.scale(200)
.translate([300, 350]);
const path = d3.geoPath().projection(projection);
const group = canvas.append("g")
d3.json(geoJsonURL).then(function (data) {
group.selectAll("g")
.data(data.features)
.enter()
.append("path")
.attr("stroke", "blue")
.attr("stroke-width", 1)
.attr("fill", "none")
.attr("d", path);
//.attr("d", path.pointRadius(20));
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>
<body>
<div id="map"></div>
</body>
【问题讨论】:
标签: javascript d3.js