0.0.60 • Published 1 year ago

@hivemapper/scout v0.0.60

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Hivemapper Scout

Scout is a React UI Library for geospatial imagery visualization of Hivemapper's map data. It enables users to input a dataset of locations and seamlessly integrate with Hivemapper's Map Image API to display the associated imagery. Whether for navigation and logistics, urban planning, geographic research or other location monitoring use cases, the Scout UI Library is the easiest way to plug into the world's freshest street-level imagery.

The Scout UI library is made of up different components that enable you to quickly interact with fresh geo-located imagery. Examples of these UI components are shown below:

Location

Everytime a locations is mapped, a new collection appears enabling you to travel in time across that location.

component UI

Location - Expanded List

Quickly glance at many locations at once.

hivemapper scout list expanded

Location - List

Manage and upload locations.

location-scout-list

Locations - Map

Monitor locations from a map interace and review key metrics.

location-map

Installation

npm:

npm install @hivemapper/scout

yarn:

yarn add @hivemapper/scout

pnpm:

pnpm add @hivemapper/scout

Before Getting Started

Before using Scout, ensure you have the following:

  • Mapbox Access Token: Necessary for map rendering and geospatial functionalities. Obtain it from Mapbox.
  • Hivemapper Username: Your unique username for logging into Hivemapper. Visit Hivemapper Login.
  • Hivemapper API Key: Essential for authenticating with the Hivemapper API. Generate this key on the Hivemapper Developer Page.
  • API Credits: These are required to use Hivemapper APIs. To purchase credits, visit the Hivemapper Console.

Locations Dataset Format

The locations dataset for Scout should be an array of ScoutLocation objects. Each ScoutLocation object has the following structure:

export interface InputLocation {
  geojson: {
    // Geospatial data in GeoJSON format
    type: "Polygon" | "MultiPolygon"; // Type of GeoJSON object
    coordinates: Coordinates[] | Coordinates[][]; // Coordinates array
  };
  name: string; // Location name
  description?: string; // Optional description
  tags?: string[]; // Optional array of tags
}
import { InputLocation } from "@hivemapper/scout";

const locations: InputLocation[] = [
  {
    geojson: {
      type: "Polygon",
      coordinates: [
        [
          [-97.74848379487175, 30.269797133209707],
          [-97.74825643127735, 30.269797133209707],
          [-97.74825643127735, 30.26940440211014],
          [-97.7486149661761, 30.269464822381238],
          [-97.74862371092993, 30.26963097793636],
          [-97.74848379487175, 30.269797133209707],
        ],
      ],
    },
    name: "6th Street",
    description: "Sewer excavation construction site",
    tags: ["sidewalk", "bike path"],
  },
  {
    geojson: {
      type: "Polygon",
      coordinates: [
        [
          [-97.76030405541717, 30.29320863703245],
          [-97.75940735917186, 30.292273071825477],
          [-97.76007988135585, 30.290853576539803],
          [-97.76090185291376, 30.29182141646328],
          [-97.76030405541717, 30.29320863703245],
        ],
      ],
    },
    name: "North Mopac Expressway",
    description: "Overpass renovation site",
    tags: ["right lane"],
  },
];

Styles

The Scout UI library utilizes Tailwind CSS and Shadcn for styling. To use the default styles provided by Scout, import the CSS file from the package into your app:

import "@hivemapper/scout/index.css";

See the Config section for additional styling options.

Using the Demo

To use the Scout demo in your project, import it from the package:

import { Demo } from "@hivemapper/scout";
export interface DemoProps {
  locations?: InputLocation[];
  geojson?: GeoJSONFeatureCollection;
  mapAccessToken: string;
  apiKey: string;
  username: string;
  mapDefaultCoords?: LngLatLike; // Default center point of Map View
  mapStyle?: string; // Mapbox style for Map and Minimap components
  darkMode?: boolean; // Dark themed components (See Styles section)
  stripTailwindClasses?: boolean; // Option to strip out Tailwind CSS classes from DOM (See Styles section)
}

After importing, you can integrate the Demo component into your application to explore its features and functionalities.

Scout UI Components

Scout provides UI components which can be individually integrated into your application as needed.

import { Location, Map, List } from "@hivemapper/scout";
export interface LocationProps {
  location: ScoutLocation;
  mapAccessToken: string;
  mapStyle?: string;
  username: string;
  apiKey: string;
  isFirstResult?: boolean;
}

Config

The Config Higher Order Component in Scout allows for additional configuration options:

  • darkMode (boolean): Enables the dark theme palette.
  • stripTailwindClasses (boolean): Removes Tailwind CSS utility classes to avoid class name collisions.
  • mapAccessToken (string): For easy access.

Usage:

<Config darkMode>
  <Location {...props} />
</Config>

useConfig Hook

The useConfig hook provides a convenient way to access configuration settings within the scope of the Config Higher Order Component. This hook can be used throughout your application to retrieve and utilize the current configuration.

Usage:

// Component must be within the scope of the Config component
const { darkMode, stripTailwindClasses, mapAccessToken } = useConfig();
0.0.60

1 year ago

0.0.59

1 year ago

0.0.58

1 year ago

0.0.57

1 year ago

0.0.54

1 year ago

0.0.55

1 year ago

0.0.56

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.51

1 year ago

0.0.50

1 year ago

0.0.49

1 year ago

0.0.47

1 year ago

0.0.48

1 year ago

0.0.46

1 year ago

0.0.44

1 year ago

0.0.45

1 year ago

0.0.42

1 year ago

0.0.43

1 year ago

0.0.40

1 year ago

0.0.41

1 year ago

0.0.39

1 year ago

0.0.38

1 year ago

0.0.37

1 year ago

0.0.30

1 year ago

0.0.31

1 year ago

0.0.32

1 year ago

0.0.33

1 year ago

0.0.34

1 year ago

0.0.35

1 year ago

0.0.36

1 year ago

0.0.26

1 year ago

0.0.27

1 year ago

0.0.28

1 year ago

0.0.29

1 year ago

0.0.24

1 year ago

0.0.25

1 year ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago