{"id":6014,"date":"2022-12-28T17:47:49","date_gmt":"2022-12-28T14:17:49","guid":{"rendered":"https:\/\/en.geobox.ir\/developers\/?post_type=docs&#038;p=6014"},"modified":"2023-01-21T12:51:11","modified_gmt":"2023-01-21T09:21:11","slug":"data-manipulation-2","status":"publish","type":"docs","link":"https:\/\/en.geobox.ir\/developers\/docs\/features\/data-manipulation-2\/","title":{"rendered":"Working with feature layer"},"content":{"rendered":"<p>Tip: fLayer variable is the name of the layer that is created from the newFeatureLayer class. To learn how to create a featureLayer, read <a href=\"https:\/\/en.geobox.ir\/developers\/docs\/features\/create-feature-layer-and-add-to-map\/\">creating a featureLayer from vector layer<\/a>.<\/p>\n<h3>Properties:<\/h3>\n<h3>selectionSet<\/h3>\n<p>After selecting features, you can access the list of selected Ids using selectionSet.<\/p>\n<p id=\"zoomin-returns\" class=\"unprose txt-m mb3 anchor mt12\"><strong>Returns:<\/strong><\/p>\n<p class=\"unprose txt-m mb3 anchor mt12\">Set: Returns a set of ids<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" dir=\"ltr\" style=\"min-height: 40px;\" data-enlighter-language=\"generic\">const Ids = fLayer.selectionSet;<\/pre>\n<h3>Methods:<\/h3>\n<h3>zoomToAll()<\/h3>\n<p>Zooms to the layer extent.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">fLayer.zoomToAll();<\/pre>\n<h3>select(Ids)<\/h3>\n<p>Selects one or multiple features.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>Ids (Number| Array): Comma separated list of ids of features. If you want a single feature, insert id as a number.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">fLayer.select([10.20]);<\/pre>\n<h3>addToSelection(Ids)<\/h3>\n<p>Adds one or multiple features from the layer to the selected features.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>Ids (Number| Array): Comma separated list of ids of features. If you want a single feature, insert id as a number.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" dir=\"ltr\" style=\"min-height: 40px;\" data-enlighter-language=\"generic\">fLayer.addToSelection([10.20]); \r\n\r\n<\/pre>\n<h3>removeFromSelection(Ids)<\/h3>\n<p>Deselects one or multiple features.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>Ids (Number| Array): Comma separated list of ids of features. If you want a single feature, insert id as a number.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" dir=\"ltr\" style=\"min-height: 40px;\" data-enlighter-language=\"generic\">fLayer.removeFromSelection([10.20]); \r\n\r\n<\/pre>\n<h3>selectByBounds(latLngBounds)<\/h3>\n<p>Selects all features within the specified bounding box.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>latLngBounds (Object): <a href=\"https:\/\/leafletjs.com\/reference.html#latlngbounds\">Leaflet latLngBounds<\/a> object.<\/p>\n<p><strong>Returns:<\/strong><\/p>\n<p>Set: Returns selection set.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" dir=\"ltr\" style=\"min-height: 40px;\" data-enlighter-language=\"generic\">vat bounds = L.latLngBounds([35,51],[36,52]);\r\nfLayer.selectByBounds(bounds); \r\n<\/pre>\n<h3>selectByDrawingBounds()<\/h3>\n<p>Another way to select all features within a bounding box is to run selectByDrawingBounds method. After executing this method, the map will be in the drawing mode, and after drawing the target bounding box, the features within that bounding box will be selected.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" dir=\"ltr\" style=\"min-height: 40px;\" data-enlighter-language=\"generic\">fLayer.selectByDrawingBounds(); \r\n<\/pre>\n<h3>clearSelection()<\/h3>\n<p>Deselects all features.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" dir=\"ltr\" style=\"min-height: 40px;\" data-enlighter-language=\"generic\">fLayer.clearSelection(); \r\n<\/pre>\n<h3>flash(Id)<\/h3>\n<p>Sets a feature to blink.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>Id (Number): A feature id.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" dir=\"ltr\" style=\"min-height: 40px;\" data-enlighter-language=\"generic\">fLayer.flash(10); \r\n<\/pre>\n<h3>zoomTo(Id)<\/h3>\n<p>Zooms to the feature.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>Id (Number): A feature id.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" dir=\"ltr\" style=\"min-height: 40px;\" data-enlighter-language=\"generic\">fLayer.zoomTo(10);<\/pre>\n<h3>panTo(Id)<\/h3>\n<p>Moves the map view to the feature location.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>Id (Number): A feature id.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" dir=\"ltr\" style=\"min-height: 40px;\" data-enlighter-language=\"generic\">fLayer.panTo(10);<\/pre>\n<h3>openPopup(Id, latLngArray)<\/h3>\n<p>Opens the feature popup.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>Id (Number): A feature id.<\/p>\n<p>latLngArray (Array)?: An array includes latitude and longitude. e.g. [32, 51]. <span style=\"font-size: 12pt;\">If you want to open popup in another location, use this parameter.<\/span><\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" dir=\"ltr\" style=\"min-height: 40px;\" data-enlighter-language=\"generic\">fLayer.openPopup(\"&lt;feature Id (number)&gt;\",\"&lt;latLng&gt;\");<\/pre>\n<h3>beginEdit(Id, options)<\/h3>\n<p>If you give the Id of the feature in beginEdit, the existing feature geometry will be placed in edit mode, otherwise sets the map in the drawing mode to draw new feature.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>Id (Number)?: A feature id.<\/p>\n<p>options (Object)<\/p>\n<table class=\"table table--fixed table--compact\" style=\"width: 82.5238%; height: 121px;\">\n<thead>\n<tr class=\"bg-gray-faint\" style=\"height: 26px;\">\n<th style=\"text-align: left; height: 42px; width: 22.9905%;\">Name<\/th>\n<th style=\"text-align: left; height: 42px; width: 103.063%;\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 26px;\">\n<td style=\"height: 26px; width: 22.9905%; text-align: left;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.actionButtons<\/div>\n<div>Boolean<\/div>\n<div>Default: true<\/div>\n<\/td>\n<td style=\"height: 26px; width: 103.063%; text-align: left;\">If true, &#8216;save&#8217; and &#8216;cancel&#8217; buttons will be shown. Otherwise, these buttons will not be shown.<\/td>\n<\/tr>\n<tr style=\"height: 53px;\">\n<td style=\"height: 53px; width: 22.9905%; text-align: left;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.explodeMultiGeometries<\/div>\n<div>\n<div>Boolean<\/div>\n<div>Default: true<\/div>\n<\/div>\n<\/td>\n<td style=\"height: 53px; width: 103.063%; text-align: left;\">If true, multi-geometries will be exploded.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" dir=\"ltr\" style=\"min-height: 40px;\" data-enlighter-language=\"generic\">fLayer.beginEdit(10, {actionButtons: true, explodeMultiGeometries: true});\r\n<\/pre>\n<h3>saveEdit(options)<\/h3>\n<p>Saves the changes applied to the feature geometry.<\/p>\n<p><strong>Parameters:<\/strong><\/p>\n<p>options (Object)?<\/p>\n<table class=\"table table--fixed table--compact\" style=\"width: 82.5238%; height: 121px;\">\n<thead>\n<tr class=\"bg-gray-faint\" style=\"height: 26px;\">\n<th style=\"text-align: left; height: 42px; width: 22.9905%;\">Name<\/th>\n<th style=\"text-align: left; height: 42px; width: 103.063%;\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 26px;\">\n<td style=\"height: 26px; width: 22.9905%; text-align: left;\">\n<div class=\"txt-mono txt-bold txt-break-word\">options.showSpinner<\/div>\n<div>Boolean<\/div>\n<div>Default: true<\/div>\n<\/td>\n<td style=\"height: 26px; width: 103.063%; text-align: left;\">If true, a spinner will spin until the process is finished.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" dir=\"ltr\" style=\"min-height: 40px;\" data-enlighter-language=\"generic\">fLayer.saveEdit({showSpinner: true});<\/pre>\n<h3>cancelEdit ()<\/h3>\n<p>Cancels the changes applied to the feature geometry.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" dir=\"ltr\" style=\"min-height: 40px;\" data-enlighter-language=\"generic\">fLayer.cancelEdit();<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Tip: fLayer variable is the name of the layer that is created from the newFeatureLayer class. To learn how to create a featureLayer, read creating a featureLayer from vector layer. Properties: selectionSet After selecting features, you can access the list of selected Ids using selectionSet. Returns: Set: Returns a set of ids Example: const Ids [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[63],"doc_tag":[],"class_list":["post-6014","docs","type-docs","status-publish","hentry","doc_category-features"],"_links":{"self":[{"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/docs\/6014","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/comments?post=6014"}],"version-history":[{"count":23,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/docs\/6014\/revisions"}],"predecessor-version":[{"id":6644,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/docs\/6014\/revisions\/6644"}],"wp:attachment":[{"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/media?parent=6014"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/doc_category?post=6014"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/en.geobox.ir\/developers\/wp-json\/wp\/v2\/doc_tag?post=6014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}