gpt4 book ai didi

javascript - 在gisMap上画一个圆

转载 作者:行者123 更新时间:2023-11-29 14:42:30 25 4
gpt4 key购买 nike

我不知道如何在 gismap 上画一个圆。

点击按钮功能后获得圆的半径 (val)。如果半径 == 1 那么我想使用这条线作为圆心 (21.1, 52.14) 在 map 上的半径 1 上绘制圆。

如何使用 d3.js 做到这一点?

代码:

function map()
{
var map;

require(["esri/map", "dojo/domReady!"], function(Map) {
map = new Map("map", {
basemap: "topo", //For full list of pre-defined basemaps, navigate to http://arcg.is/1JVo6Wd
center: [14.70, 52.53], // longitude, latitude
zoom: 6
});
});

}

function DrawCircle()
{
var val = document.getElementById("InputMin1").value;

if(val == 1)
{
var svg = d3.select('svg');
var originX = 21.1;
var originY = 52.14;
var outerCircleRadius = 100;

var outerCircle = svg.append("circle").attr({
cx: originX,
cy: originY,
r: outerCircleRadius,
fill: "none",
stroke: "black"
});
}

最佳答案

好吧,据我了解,您只想在 esri map 上添加一个一定距离的圆。

在运行示例下方,在中心 (21.1, 52.14) 上画一个圆。

var map;

require(["esri/map", "esri/geometry/Circle", "esri/layers/GraphicsLayer","esri/graphic", "esri/units", "esri/geometry/Point", "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "esri/Color"], function(Map, Circle,GraphicsLayer, Graphic, Units, Point,SimpleFillSymbol, SimpleLineSymbol, Color) {
map = new Map("map", {
basemap: "topo",
center: [14.70, 52.53], // longitude, latitude
zoom: 5
});

var centerPoint = new Point([21.1, 52.14]);
var circleGeometry = new Circle({
center: centerPoint,
radius: 100, // add distance
radiusUnit: Units.MILES, // add distance unit
geodesic: true
});
var gl = new GraphicsLayer({ id: "circles" });
map.addLayer(gl);
var sfs = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,
new Color([255,0,0]), 2),new Color([255,255,0,0.25])
);
var graphic = new Graphic(circleGeometry,sfs);
gl.add(graphic);
});
html, body, #map {
height: 100%;
margin: 0;
padding: 0;
}
<link rel="stylesheet" href="https://js.arcgis.com/3.16/esri/css/esri.css">
<script src="https://js.arcgis.com/3.16/"></script>



<body>
<div id="map"></div>
</body>

希望这对您有所帮助:)

关于javascript - 在gisMap上画一个圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36864528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com