---
description: API for creating and modifying line objects.
---

# JSLineString

> Create a API with Module.createLineString.

```javascript
var object = Module.createLineString("ID");
```

## Function

### createbyJson(option) → string

> Creates a line object.
>
> Set the line object using the argument variable.

{% tabs %}
{% tab title="Information" %}
| Name   | Type                                                      | Description                      |
| ------ | --------------------------------------------------------- | -------------------------------- |
| option | [JSLineString.CreateOptions](#jslinestring.createoptions) | Initialization option properties |

* Return
  * "success": Creation successful.
  * Other error messages including the cause of the error
* Sample
  * Refer to function createLine.
  * [Sandbox\_Line](https://sandbox.egiscloud.com/code/main.do?id=object_line_Json)
{% endtab %}

{% tab title="Template" %}
```javascript
```
{% endtab %}
{% endtabs %}

### getBoundary() → [JSAABBox3D](../core/jsaabbox3d)

> Returns the object's boundary.

{% tabs %}
{% tab title="Information" %}
* Return
  * [JSAABBox3D](../core/jsaabbox3d): The function successfully returns the object's bounds.
  * null: Object bounds return failed.
{% endtab %}

{% tab title="Template" %}
```javascript
var boundary = object.getBoundary();
var boundary_min = boundary.min;
var boundary_max = boundary.max;
```
{% endtab %}
{% endtabs %}

### getCenter() → [JSVector3D](../core/jsvector3d)

> Returns the center point of the object.

{% tabs %}
{% tab title="Information" %}
* Return
  * [JSVector3D](../core/jsvector3d): Returns the centroid coordinates (longitude, latitude, altitude) of the object successfully.
  * null: Coordinate return failed.
{% endtab %}

{% tab title="Template" %}
```javascript
var vCenter = object.getCenter();
var dCenterLon = vCenter.Longitude;
var dCenterLat = vCenter.Latitude;
var dCenterAlt = vCenter.Altitude;
```
{% endtab %}
{% endtabs %}

### getExtent() → number

> Returns the distance between Min-Max of the object boundary Box.

{% tabs %}
{% tab title="Information" %}
* Return
  * number: Distance between Min-Max of the object boundary Box.
{% endtab %}

{% tab title="Template" %}
```javascript
var bExtends = object.getExtent();
```
{% endtab %}
{% endtabs %}

### getId() → string

> Returns the ID of the object.

{% tabs %}
{% tab title="Information" %}
* Return
  * string: Successful return of the object's Key string.
  * null: If the object is null.
{% endtab %}

{% tab title="Template" %}
```javascript
lat strKey = object.getId();
```
{% endtab %}
{% endtabs %}

### getLength(terrain) → number

> Returns the length of the line.

{% tabs %}
{% tab title="Information" %}
| Name    | Type    | Description                                                                                                                                                                                                                                                                        |
| ------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| terrain | boolean | <p>Whether to consider terrain union.<br>true: Calculates the length considering terrain height by combining the line with the terrain.<br>false: Calculates the length through distance calculation of the input coordinate list without combining the line with the terrain.</p> |

* Return
  * number(0 or higher): Successful return of the line length.
  * number(-1.0): If the object is null.
{% endtab %}

{% tab title="Template" %}
```javascript
var length = object.getLength();
```
{% endtab %}
{% endtabs %}

### SetDashType(dash) → boolean

> Set line spacing.

{% tabs %}
{% tab title="Information" %}
| Name | Type   | Description   |
| ---- | ------ | ------------- |
| dash | number | Dash interval |

* Return
  * true: Successful object option setting.
  * false: Failed object option setting.
{% endtab %}

{% tab title="Template" %}
```javascript
```
{% endtab %}
{% endtabs %}

### setPartCoordinates(coordinates, parts)

> Creates a line object.
>
> A minimum of 3 components for coordinates is required.
>
> A minimum of 1 component for parts is required.

{% tabs %}
{% tab title="Information" %}
| Name        | Type                               | Description                                        |
| ----------- | ---------------------------------- | -------------------------------------------------- |
| coordinates | [JSVec3Array](../core/jsvec3array) | List of longitude, latitude, altitude coordinates. |
| parts       | [Collection](../core/collection)   | List of point counts composing the line.           |

* Sample
  * Refer to function createBufferPolygon.
  * [Sandbox\_Line Buffering](https://sandbox.egiscloud.com/code/main.do?id=object_line_buffering)
{% endtab %}

{% tab title="Template" %}
```javascript
```
{% endtab %}
{% endtabs %}

### setUnionMode(type)

> Line visualization option.
>
> Sets whether the line is combined with the terrain.

{% tabs %}
{% tab title="Information" %}
| Name | Type    | Description                                                                         |
| ---- | ------- | ----------------------------------------------------------------------------------- |
| type | boolean | <p>true for terrain union visualization (RTT)<br>false for basic visualization.</p> |

* Sample
  * Refer to function createObjectToPathPosition .
  * [Sandbox\_Path Analysis](https://sandbox.egiscloud.com/code/main.do?id=analysis_line_path_distance)
{% endtab %}

{% tab title="Template" %}
```javascript
```
{% endtab %}
{% endtabs %}

## Getter / Setter

### getDescription(), setDescription(desc) → string

> Set a description for the object.

{% tabs %}
{% tab title="Information" %}
| Name | Type   | Description                |
| ---- | ------ | -------------------------- |
| desc | string | Object description string. |

* Return
  * string: Successful return of the object's description string.
  * null: If the object is null.
{% endtab %}

{% tab title="Template" %}
```javascript
var strDesc = object.getDescription();
// ... or ...
object.setDescription("First Object.");
```
{% endtab %}
{% endtabs %}

### getName(), setName(name) → string

> Sets the name of the object.

{% tabs %}
{% tab title="Information" %}
| Name | Type   | Description                     |
| ---- | ------ | ------------------------------- |
| name | string | The name to set for the object. |

* Return
  * string: Successful return of the object's name.
  * null: If the object is null.
{% endtab %}

{% tab title="Template" %}
```javascript
var objName = object.getName();
// ... or ...
object.setName("MyObject");
```
{% endtab %}
{% endtabs %}

### getVisible(), setVisible(visible) → boolean

> Sets the visibility state of an object.

{% tabs %}
{% tab title="Information" %}
| Name    | Type    | Description                                                      |
| ------- | ------- | ---------------------------------------------------------------- |
| visible | boolean | <p>true: Make the object visible.<br>false: Hide the object.</p> |

* Return
  * true: Object visible state.
  * false: Object hidden state.
{% endtab %}

{% tab title="Template" %}
```javascript
var objName = object.getName();
// ... or ...
object.setVisible(true);
```
{% endtab %}
{% endtabs %}

### getCoordinates(), setCoordinates(coordinates) → [Collection](../core/collection)

> Sets the list of coordinates for the line object.
>
> A minimum of 3 components for coordinates is required.

{% tabs %}
{% tab title="Information" %}
| Name        | Type                             | Description                                        |
| ----------- | -------------------------------- | -------------------------------------------------- |
| coordinates | [Collection](../core/collection) | List of longitude, latitude, altitude coordinates. |

* Return
  * [Collection](../core/collection): List of coordinates.
* Sample
  * Refer to function createPathLine.
  * [Sandbox\_Path Analysis](https://sandbox.egiscloud.com/code/main.do?id=analysis_line_path_distance)
{% endtab %}

{% tab title="Template" %}
```javascript
var coorList = object.getCoordinates();
```
{% endtab %}
{% endtabs %}

### getStyle(), setStyle(style) → [JSPolyLineStyle](jspolylinestyle)

> Changes the line style with options applied in [JSPolyLineStyle](jspolylinestyle).
>
> Sets color, thickness, and opacity.

{% tabs %}
{% tab title="Information" %}
| Name  | Type                               | Description  |
| ----- | ---------------------------------- | ------------ |
| style | [JSPolyLineStyle](jspolylinestyle) | Object style |

* Return
  * Valid object style ([JSPolyLineStyle](jspolylinestyle)): Successful return of the object style.
  * Simple initialized state of object style ([JSPolyLineStyle](jspolylinestyle)): If the object is null.
* Sample
  * Refer to function createBufferPolygon.
  * [Sandbox\_Line Buffering](https://sandbox.egiscloud.com/code/main.do?id=object_line_buffering)
{% endtab %}

{% tab title="Template" %}
```javascript
var objectStyle = polyLine.getStyle();
```
{% endtab %}
{% endtabs %}

### Type Definitions

#### JSLineString.CreateOptions

> Options for creating a line object.

| Name        | Type                                                    | Attributes | Default                     | Description                                                                         |
| ----------- | ------------------------------------------------------- | ---------- | --------------------------- | ----------------------------------------------------------------------------------- |
| coordinates | [coordinates Type](../../etc/tag-list#coordinates-type) |            |                             | Vertex management options.                                                          |
| type        | number                                                  | optional   | 0                           | Line visualization type.                                                            |
| skip        | number                                                  | optional   | 1                           | Animation detail option.                                                            |
| width       | number                                                  | optional   | 1                           | Line thickness option.                                                              |
| dash        | number                                                  | optional   | 0                           | Dash interval option.                                                               |
| speed       | number                                                  | optional   | 0                           | Animation speed option.                                                             |
| union       | boolean                                                 | optional   | false                       | <p>true for terrain union visualization (RTT)<br>false for basic visualization.</p> |
| depth       | boolean                                                 | optional   | true                        |                                                                                     |
| color       | [JSColor](../core/jscolor)                              | optional   | JSColor(200, 255, 255, 255) | Line visualization color.                                                           |
