# setAttributes()

Esta función se encarga de agregar un múltiples atributos a algún elemento que encuentre almacenado en la variable global "systemElements", ya sean activos (assets), conductores (drivers), etc.

<details class="mb-m" id="bkmrk-body-parametersparam"><summary class="text-muted">Esta función recibe como parámetro un objeto JSON con los siguientes atributos:</summary>

<div></div><div><table class="table" style="height: 656px; width: 619px;" width="811"><tbody><tr style="height: 41px;"><th style="width: 320px; height: 41px;">Atributos</th><th style="width: 301px; height: 41px;">Definición </th></tr><tr style="height: 41px;"><td style="width: 320px; height: 41px;"><div><div>element</div></div></td><td style="width: 301px; height: 41px;">Cadena con la que se definió el elemento a obtener.

</td></tr><tr style="height: 41px;"><td style="width: 320px; height: 41px;"><div><div>key</div></div></td><td style="width: 301px; height: 41px;">Identificador en el cual se puede acceder a la información de los elementos.</td></tr><tr><td style="width: 320px;"><div><div><div>attributes</div></div></div><div><div></div></div></td><td style="width: 301px;">Es el json donde se agregan los atributos y sus valores</td></tr></tbody></table>

</div></details>Para este ejemplo se agregaran varios atributos a un elemento de activos (assets) que se encuentra en la variable "systemElements"<span style="color: #bbbbbb; font-size: 1.4em; font-weight: 400;">.</span>

<span style="color: #bbbbbb; font-size: 1.4em; font-weight: 400;">Ejemplo de solicitud en JS para almacenar conductores:</span>

```JavaScript
try {
       _gpsApiv2.setAttributes({ element: 'assets', key: '0aa30b6cd600c3a3OLD', attributes:{atributo: 1,atributotwo:'2',atributotree:'3'} });
 	} catch (error) {
	   console.error(error);
	}
```

<span style="color: #bbbbbb; font-size: 1.4em; font-weight: 400;">Ejemplo de elemento "0aa30b6cd600c3a3OLD" antes de agregar los atributos:</span>

```JavaScript
{
  Address: ""
  Alto_icono: 60
  Ancho_icono: 60
  DatosJson: {datos_extras: {…}}
  Equipo: "0aa30b6cd600c3a3OLD"
  FechaHora: "2022-05-04 17:29:09"
  Icono: "https://plataforma.service24gps.com/commons/svg/3d_camion_caja.php?c=f7f7f7&b=f40b0b&p=235&t=FF3637&f=F39C12"
  IdVehiculo: "138584"
  Latitud: "-15.34409226358717"
  Longitud: "-75.1444648522207"
  Nombre: "0aa30b6cd600c3a3"
  Placa: "0aa30b6cd600c3a3"
  Velocidad: "60"
  lat: "-15.34409226358717"
  lat_lon: "-15.34409226358717,-75.1444648522207"
  lng: "-75.1444648522207"
  marker: _.Ig {__gm: {…}, gm_accessors_: {…}, position: _.Ee, gm_bindings_: {…}, title: '', …}
  [[Prototype]]: Object
}
```

<span style="color: #bbbbbb; font-size: 1.4em; font-weight: 400;">Ejemplo de elemento "0aa30b6cd600c3a3OLD" después de agregar varios atributos:</span>

<div data-lang="JavaScript" id="bkmrk-"><div></div></div>```JavaScript
{
 Address: ""
Alto_icono: 60
Ancho_icono: 60
DatosJson: {datos_extras: {…}}
Equipo: "0aa30b6cd600c3a3OLD"
FechaHora: "2022-05-04 17:29:09"
Icono: "https://plataforma.service24gps.com/commons/svg/3d_camion_caja.php?c=f7f7f7&b=f40b0b&p=235&t=FF3637&f=F39C12"
IdVehiculo: "138584"
Latitud: "-15.34409226358717"
Longitud: "-75.1444648522207"
Nombre: "0aa30b6cd600c3a3"
Placa: "0aa30b6cd600c3a3"
Velocidad: "60"
atributo: "1"
atributotree: "3"
atributotwo: "2"
lat: "-15.34409226358717"
lat_lon: "-15.34409226358717,-75.1444648522207"
lng: "-75.1444648522207"
marker: _.Ig {__gm: {…}, gm_accessors_: {…}, position: _.Ee, gm_bindings_: {…}, title: '', …}
[[Prototype]]: Object
}
```