In the last post, we created polygon geometry using polygon library. Today in this post, i will describe how to create circle using "circle library" with Esri ArcGIS JS API. And we will add this circle to map graphically.
We will learn how to create circle using ArcGIS JS API "circle library".
You can use any operating system and any ide or editor. I will use "Windows PC" and "Visual Studio Code". And i will use ESRI ArcGIS JS Library from web. But you can install library using bower from github repository.
| -- ESRI ArcGIS JS API 3.23
| -- | -- js
| -- | -- | -- main.js
| -- | -- css
| -- | -- | -- main.css
| -- | -- fonts
| -- | -- | -- font-awesome-4.7.0
| -- | -- | -- | -- css
| -- | -- | -- | -- |-- font-awesome.min.css
| -- | -- | -- | -- fonts
| -- | -- | -- | -- less
| -- | -- | -- | -- scss
| -- | -- index.html
*Only used files in project has been shown. There are other files for dependency.
Firstly we will create circle using ESRI ArcGIS JS API "Circle" library. We will work in "main.js" file.
We will add circle library using require method.
require([
"esri/geometry/Circle"
], function (
Circle
){...});
Now, we can create circle instance. We will use two parameters. First parameter is center of circle. It is a point geometry. We learned how to create point previous post. Second parameter is options for circle geometry. We will use two properties. Radius is circle and geodesic for well shape circle.
Radius unit is meter and that default value is 1000. Geodesic type is boolean and default value is false.
var circle = new Circle(new Point(28.991808, 41.014267), {
radius: 1000,
geodesic: true
});
We will create simple fill symbol to show our circle on map.
We will add simple fill symbol library using require method.
require([
"esri/symbols/SimpleFillSymbol"
], function (
SimpleFillSymbol
){...});
We will create new symbol instance. We will not use any parameters for now. But we will learn how to create special symbol in future posts.
var simpleFillSymbol = new SimpleFillSymbol();
We learned how to create graphic previous post. We will create new graphic instance using two parameters. First parameter is geometry for this example it will be our circle. And second parameter is symbol for this example it will be our simple fill symbol.
var circleGraphic = new Graphic(circle, simpleFillSymbol);
Now, we can add circle graphic to graphics layer using add method.
graphicsLayer.add(circleGraphic);
We can see the result by running the "index.html" file.
We learned how to create circle geometry and add to map using ArcGIS JS API and Dojo in web.
Thank you for your attention and see you next time!
You can view old post below links.