在gisMap上画一个圆

Draw a circle on gisMap

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

点击按钮功能后获得圆的半径 (val)。 如果半径 == 1 那么我想使用这条线作为圆心 (21.1, 52.14) 在地图上的半径 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"
        });
    }

}

我知道这不能回答有关 D3.js 的问题,但如果没有使用 D3 的特定原因,为什么不使用 esri/geometry/Circle 模块?它已包含在 Esri JS API 中,因此您无需引入额外的库。

A circle (Polygon) created by a specified center point. This point can be provided as an esri/geometry/Point object or an array of latitude/longitude values.

参考:https://developers.arcgis.com/javascript/jsapi/circle-amd.html

示例:https://developers.arcgis.com/javascript/jssamples/graphics_create_circles.html

嗯,据我了解,您只是想在 esri 地图上添加一个一定距离的圆。

下面运行示例在圆心(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>

希望对您有所帮助:)