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 = fLayer.selectionSet;
Methods:
zoomToAll()
Zooms to the layer extent.
Example:
fLayer.zoomToAll();
select(Ids)
Selects one or multiple features.
Parameters:
Ids (Number| Array): Comma separated list of ids of features. If you want a single feature, insert id as a number.
Example:
fLayer.select([10.20]);
addToSelection(Ids)
Adds one or multiple features from the layer to the selected features.
Parameters:
Ids (Number| Array): Comma separated list of ids of features. If you want a single feature, insert id as a number.
Example:
fLayer.addToSelection([10.20]);
removeFromSelection(Ids)
Deselects one or multiple features.
Parameters:
Ids (Number| Array): Comma separated list of ids of features. If you want a single feature, insert id as a number.
Example:
fLayer.removeFromSelection([10.20]);
selectByBounds(latLngBounds)
Selects all features within the specified bounding box.
Parameters:
latLngBounds (Object): Leaflet latLngBounds object.
Returns:
Set: Returns selection set.
Example:
vat bounds = L.latLngBounds([35,51],[36,52]); fLayer.selectByBounds(bounds);
selectByDrawingBounds()
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.
Example:
fLayer.selectByDrawingBounds();
clearSelection()
Deselects all features.
Example:
fLayer.clearSelection();
flash(Id)
Sets a feature to blink.
Parameters:
Id (Number): A feature id.
Example:
fLayer.flash(10);
zoomTo(Id)
Zooms to the feature.
Parameters:
Id (Number): A feature id.
Example:
fLayer.zoomTo(10);
panTo(Id)
Moves the map view to the feature location.
Parameters:
Id (Number): A feature id.
Example:
fLayer.panTo(10);
openPopup(Id, latLngArray)
Opens the feature popup.
Parameters:
Id (Number): A feature id.
latLngArray (Array)?: An array includes latitude and longitude. e.g. [32, 51]. If you want to open popup in another location, use this parameter.
Example:
fLayer.openPopup("<feature Id (number)>","<latLng>");
beginEdit(Id, options)
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.
Parameters:
Id (Number)?: A feature id.
options (Object)
Name | Description |
---|---|
options.actionButtons
Boolean
Default: true
|
If true, ‘save’ and ‘cancel’ buttons will be shown. Otherwise, these buttons will not be shown. |
options.explodeMultiGeometries
Boolean
Default: true
|
If true, multi-geometries will be exploded. |
Example:
fLayer.beginEdit(10, {actionButtons: true, explodeMultiGeometries: true});
saveEdit(options)
Saves the changes applied to the feature geometry.
Parameters:
options (Object)?
Name | Description |
---|---|
options.showSpinner
Boolean
Default: true
|
If true, a spinner will spin until the process is finished. |
Example:
fLayer.saveEdit({showSpinner: true});
cancelEdit ()
Cancels the changes applied to the feature geometry.
Example:
fLayer.cancelEdit();