# hypertrack-views-react

> A wrapper for views provided through the [HyperTrack dashboard](https://dashboard.hypertrack.com/). It allows you to integrate the same views into your own application.

Latest version **1.1.30** (published 2020-02-29) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install hypertrack-views-react
pnpm add hypertrack-views-react
yarn add hypertrack-views-react
bun add hypertrack-views-react
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.30 |
| Published | 2020-02-29 |
| First published | 2019-08-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 27 |
| Unpacked size | 233.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 7 |
| Maintainers | hypertrack |

## Links

- npm: https://www.npmjs.com/package/hypertrack-views-react
- Repository: https://github.com/hypertrack/views-react
- npm.io page: https://npm.io/package/hypertrack-views-react

## Dependencies (27)

- [react](https://npm.io/package/react.md) ^16.8.6
- [graphql](https://npm.io/package/graphql.md) ^14.4.2
- [leaflet](https://npm.io/package/leaflet.md) ^1.5.0
- [date-fns](https://npm.io/package/date-fns.md) ^1.30.1
- [react-if](https://npm.io/package/react-if.md) ^3.4.0
- [downshift](https://npm.io/package/downshift.md) ^3.2.10
- [node-sass](https://npm.io/package/node-sass.md) ^4.12.0
- [react-dom](https://npm.io/package/react-dom.md) ^16.8.6
- [classnames](https://npm.io/package/classnames.md) ^2.2.6
- [lottie-web](https://npm.io/package/lottie-web.md) ^5.5.5
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2
- [apollo-link](https://npm.io/package/apollo-link.md) ^1.2.12
- [aws-appsync](https://npm.io/package/aws-appsync.md) ^1.8.1
- [graphql-tag](https://npm.io/package/graphql-tag.md) ^2.10.1
- [react-apollo](https://npm.io/package/react-apollo.md) ^2.5.8
- [apollo-client](https://npm.io/package/apollo-client.md) ^2.6.4
- [react-loadable](https://npm.io/package/react-loadable.md) ^5.5.0
- [lodash.debounce](https://npm.io/package/lodash.debounce.md) ^4.0.8
- [lodash.throttle](https://npm.io/package/lodash.throttle.md) ^4.1.1
- [apollo-link-http](https://npm.io/package/apollo-link-http.md) ^1.5.15
- [react-day-picker](https://npm.io/package/react-day-picker.md) ^7.3.0
- [react-animate-height](https://npm.io/package/react-animate-height.md) ^2.0.15
- [react-detect-offline](https://npm.io/package/react-detect-offline.md) ^2.3.0
- [leaflet.markercluster](https://npm.io/package/leaflet.markercluster.md) ^1.4.1
- [copy-text-to-clipboard](https://npm.io/package/copy-text-to-clipboard.md) ^2.1.0
- [leaflet.featuregroup.subgroup](https://npm.io/package/leaflet.featuregroup.subgroup.md) ^1.0.2
- [leaflet-defaulticon-compatibility](https://npm.io/package/leaflet-defaulticon-compatibility.md) ^0.1.1

## Recent versions

- 1.1.30 (latest) — 2020-02-29
- 1.1.29 — 2019-10-09
- 1.1.28 — 2019-09-26
- 1.1.27 — 2019-09-26
- 1.1.26 — 2019-09-24
- 1.1.25 — 2019-09-04
- 1.1.24 — 2019-09-04
- 1.1.22 — 2019-08-28
- 1.1.21 — 2019-08-23
- 1.1.20 — 2019-08-20
- 1.1.19 — 2019-08-20
- 1.1.18 — 2019-08-20
- 1.1.17 — 2019-08-15
- 1.1.16 — 2019-08-15
- 1.1.15 — 2019-08-14
- … 15 more at https://npm.io/package/hypertrack-views-react/versions

## README

# HyperTrack Views for ReactJS

A wrapper for views provided through the [HyperTrack dashboard](https://dashboard.hypertrack.com/). It allows you to integrate the same views into your own application.

> Please check out the [Views Guide](https://docs.hypertrack.com/#views) for a closer look at the capabilities provided by HyperTrack Views.

![sample view](public/sample.png "Sample View")

## Prerequisites

- Set up a HyperTrack account and obtain your [Publishable Key from the Dashboard](https://dashboard.hypertrack.com/setup)
- Integrate the HyperTrack SDK in your application ([iOS](https://github.com/hypertrack/quickstart-ios), [Android](https://github.com/hypertrack/quickstart-android), or [React Native](https://github.com/hypertrack/quickstart-react-native)) or use our sample app to send location data ([iOS](https://github.com/hypertrack/live-app-ios) or [Android](https://github.com/hypertrack/live-app-android))

## Explore sample app

You can use the sample app provided to explore the capabilities and usage of this component. Please [visit this page to open the sample app](https://hypertrack.github.io/views-react/).

To run the sample app on your own, follow these steps:

Jump to the sample app folder:

```shell
cd sample
```

Install all app dependencies:

```shell
npm i

yarn
```

> Note: Do not run the installation in the root folder. If that has been done before sample app dependecies were installed, NPM will use installed packages from the root node_modules, which might reason conflicts and break the build process

Run the sample app:

```shell
node run start

yarn start
```

The CLI will open up the locally hosted sample app (`http://localhost:3000/`) and should look like this:
![sample app](public/sample-app-v1.png "Sample App")

## Installation

You can use either Yarn or NPM to add `hypertrack-views-react` to your project:

```shell
npm install --save hypertrack-views-react

yarn add hypertrack-views-react
```

## Usage

```javascript
import { LiveView } from "hypertrack-views-react";

const PUBLISHABLE_KEY = "<your_key>";

<LiveView
  publishableKey={PUBLISHABLE_KEY}
  showTooltips={true}
  showDeviceList={false}
  showDeviceCard={false}
  selectedDeviceId={"00112233-4455-6677-8899-AABBCCDDEEFF"}
  defaultLayer={"custom"}
  customLayerUrl={"http://mt2.google.com/vt/lyrs=s&x={x}&y={y}&z={z}"}
  assetsUrl={"https://abc-sdk-test-assets.s3-us-west-2.amazonaws.com/"}
/>;
```

## Configuration

| Property         | Type    | Default | Description                                                                                                                                                                                                                                                 |
| ---------------- | ------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| publishableKey   | string  | N/A     | The publishable key of your account from the [Setup page on the Dashboard](https://dashboard.hypertrack.com/setup)                                                                                                                                          |
| showTooltips     | boolean | `false` | Show the device ID right next to the location marker of a device                                                                                                                                                                                            |
| showDeviceList   | boolean | `true`  | Show the list of all tracked devices, includes filter and search options. A click on a device will place zoom to the device location                                                                                                                        |
| showDeviceCard   | boolean | `true`  | Show the device detail card on the single device view                                                                                                                                                                                                       |
| selectedDeviceId | string  | `null`  | ID of the device to be displayed (case sensistive). Can be obtained using the [Device API](https://docs.hypertrack.com/#api-devices). Adding this will change the view to a single device mode (including device data, activity, and more)                  |
| defaultLayer     | string  | `base`  | Can be either one of: [`base`](https://cloud.maptiler.com/maps/voyager/), [`street`](https://cloud.maptiler.com/maps/streets/), [`satellite`](https://cloud.maptiler.com/maps/hybrid/), or `custom`. Custom will only work if a customLayerUrl is provided. |
| customLayerUrl   | string  | `null`  | URL to a Leaflet-compatible [tiled web map](https://en.wikipedia.org/wiki/Tiled_web_map) in XYZ format. Only raster is supported and it needs to be public accessible.                                                                                      |
| assetsUrl        | string  | `null`  | URL to a public asset folder containig SVG files to replace default icons. The filenames need to match exactly. Missing icons will show the default versions.                                                                                               |

> Note: The component passes along all additional properties, so you can use properties like `className`.

#### Showing a single device

When provided with the `selectedDeviceId` property, the component will render a single device view as opposed to the device overview. You can find more details in the [Live device view documentation](https://docs.hypertrack.com/#live-device-view).

![live device view](public/sample-single-device.png "Live Device View")

> The device info card on the left side can be disabled by setting `showDeviceCard` to `false`

#### Adding a custom map layer

With the `customLayerUrl` property, you can reference a raster tile to be added as a custom map layer. Users can select the custom view from the ![map-layer-icon](public/map-layer.png "map layer icon") button on the top right side of the view. The layer is pre-selected based on the `defaultLayer` property. After setting the `customLayerUrl`, you can set the `defaultLayer` property to `custom` to render this new tile by default.

There are different ways to obtain and/or generate a custom layer. [OpenMapTiles](https://openmaptiles.org/) might be of interest. You can also generate/customize [MapBox maps and access them as raster tiles](https://docs.mapbox.com/api/maps/#raster-tiles).

> Note: Please ensure you use the XYZ URL format, which looks something like this: `/tile-name/{z}/{x}/{y}.png`

Here are some sample layer tiles:

| Layer                        | URL                                                         | Preview                                                                   |
| ---------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------- |
| Google Maps: Satellite       | `http://mt0.google.com/vt/lyrs=s&x={x}&y={y}&z={z}`         | <img src="public/satellite-map.png" alt="satellite preview" width="150"/> |
| Google Maps: Roadmap/Streets | `http://mt0.google.com/vt/lyrs=m&hl=en&x={x}&y={y}&z={z}`   | <img src="public/streets-map.png" alt="streets preview" width="150"/>     |
| Google Maps: Hybrid          | `http://mt0.google.com/vt/lyrs=s,h&hl=en&x={x}&y={y}&z={z}` | <img src="public/hybrid-map.png" alt="hybrid preview" width="150"/>       |

#### Replacing default icons

By default, the views display a set of icons to indicate status, activity, and more. You can replace each icon individually. Below is a list of all the replaceable icons.

> **Original Icons**: You can use the [default icons](i) and make your modifications

| Filename             | Default                                                                                                     | Description                                               |
| -------------------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| `live-direction.svg` | <img src="https://dashboard.hypertrack.com/assets/live-direction.svg" alt="live-direction.svg" width="20"/> | Dot indicated the live location and direction of a device |
| `live.svg`           | <img src="https://dashboard.hypertrack.com/assets/live.svg" alt="live.svg" width="20"/>                     | Dot indicated the live location of a device               |
| `offline.svg`        | <img src="https://dashboard.hypertrack.com/assets/offline.svg" alt="offline.svg" width="20"/>               | Dot indicated the last known location of a device         |
| `walk.svg`           | <img src="https://dashboard.hypertrack.com/assets/walk.svg" alt="walk.svg" width="20"/>                     | Activity icon for walking activity                        |
| `run.svg`            | <img src="https://dashboard.hypertrack.com/assets/run.svg" alt="run.svg" width="20"/>                       | Activity icon for running activity                        |
| `cycle.svg`          | <img src="https://dashboard.hypertrack.com/assets/cycle.svg" alt="cycle.svg" width="20"/>                   | Activity icon for cycling activity                        |
| `drive.svg`          | <img src="https://dashboard.hypertrack.com/assets/drive.svg" alt="drive.svg" width="20"/>                   | Activity icon for driving activity                        |
| `stop.svg`           | <img src="https://dashboard.hypertrack.com/assets/stop.svg" alt="stop.svg" width="20"/>                     | Activity icon for stopping activity                       |
| `unknown.svg`        | <img src="https://dashboard.hypertrack.com/assets/unknown.svg" alt="unknown.svg" width="20"/>               | Activity icon for unknown activity                        |
| `inactive.svg`       | <img src="https://dashboard.hypertrack.com/assets/inactive.svg" alt="inactive.svg" width="20"/>             | Status icon for inactive device                           |
| `disconnected.svg`   | <img src="https://dashboard.hypertrack.com/assets/disconnected.svg" alt="disconnected.svg" width="20"/>     | Status icon for disconnected device                       |

## Versioning

We use [Semantic Versioning](http://semver.org/). For the versions available, see the [tags on this repository](https://github.com/hypertrack/views-react/tags).

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

---
_Source: https://npm.io/package/hypertrack-views-react · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
