4.14.50 • Published 2 years ago

@getcircuit/web-map v4.14.50

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@getcircuit/web-map

Circuit Schema | Svelte Documentation | Google Maps Documentation

Usage

General

The general way to use this component is to instantiate it as you would with any other Svelte component.

import CircuitMap from '@getcircuit/web-map'
import ReactDOM from 'react-dom'
import React from 'react'
import { DriverAvatar } from '@getcircuit/components'
import { AttemptedLocationCard } from '../somewhere'

const mapInstance = new CircuitMap({
  target: document.querySelector('#map'),
  props: {
    apiKey: '...',
    mapOptions: {
      center: { lat: 51.509865, lng: -0.118092 },
      zoom: 15,
    },
    react: {
      React,
      ReactDOM,
      components: {
        DriverAvatar,
        AttemptedLocationCard,
      },
    },
  },
})

API

apiKey

Google Maps API key.

mapOptions

Google maps options object.

react

Used to render react elements inside the map component. It must be an object that matches the following type:

type ReactBag = {
  React: ReactLib
  ReactDOM: ReactDOMLib
  components: {
    DriverAvatar: CircuitDriverAvatarComponent
    AttemptedLocationCard?: CircuitAttemptedLocationCard
  }

Methods

setIntl(newIntl: IntlStore): void

Updates the map's Intl bag. An Intl bag is an object composed of the following properties:

type IntlBag {
  /** Current locale */
  locale: string
  /** Method that returns a localized message given a message id */
  formatMessage: (messageId: string, values?: Record<string, any>) => string
  /** Method that formats an epoch timestamp given the current locale */
  formatEpoch: (epoch: EpochTimestamp) => string
}

setMapOptions(options: google.maps.MapOptions): void

Updates map's Google Map options.

setCenter(center: google.maps.LatLngLiteral | google.maps.LatLng): void

Changes the center of the map to the specified point.

fitCoordinates(coords?: google.maps.LatLngLiteral[]): void

Moves the map camera to fit all the passed coordinates.

setPlan(newPlan?: PlanBundle): void

Updates the current plan that is being displayed on the map. Set to undefined to remove the current plan.

focusRoute(routeId: string): void

Focuses the given route on the map.

focusStop(stopId: string): void

Focuses the given stop on the map.

resetFocus(): void

Resets the map focus state.

hoverRoute(routeId: string): void

Hovers the given route on the map.

hoverStop(stopId: string): void

Hovers the given stop on the map.

resetHover(): void

Resets the map hover state.

openAttemptedLocationCard(): void

Opens the Attempted Location Card component for the current focused stop.

closeAttemptedLocationCard(): void

Closes the Attempted Location Card component.

Map Camera

Loom

The map camera should behave as stated below:

  • Use CubicInOut for 600ms when there’s no change to zoom levels, regardless of the distance between points A and B.
  • If there’s a zoom level change, skip the animation (0 duration).
  • When focusing a stop:
    • Minimum zoom level is 16, maximum zoom level is not defined.
    • Maximum zoom level is 16 if the stop being focused has an attempted location more than 100 meters away from the original stop location and the user is on a zoom level lower than 16. If user is on a greater zoom level, try to fit the stop and attempted markers with the current zoom level.
  • The camera supports padding in px
    • The camera center is moved according to the padded area.
    • The default padding of the camera is 50px in all directions.
  • The camera should keep track of manual movements made by the user.
    • If the user has not moved the camera manually:
      • Unfocusing a route stop moves the camera to the whole stop's route.
      • Unfocusing a unassigned stop moves moves the camera to the whole plan.
    • If the user has moved the camera manually:
      • Unfocusing a stop should move the camera back to the user position, but the route should be focused.
      • Unfocusing a route should move the camera back to the user position and nothing should be on focus..

Polyline

TBD

Marker

Marker color definition

The color preset of a marker depends on its stop state with the following precedence:

  • If stop was deleted, use the neutral color preset.
  • If stop was skipped, use the error color preset.
  • (todo) If stop has an issue, use the error color preset.
  • If stop was added after an optimization, use the neutral color preset.
  • If stop was edited after an optimization, use the route's color preset.
  • If stop is part of a route, use the route's color preset.
  • If stop is not part of a route, use the default color preset.

Apart from the color preset, the colors that will be used depend on the marker variant. The available variants are: primary, secondary, focused.

  • The marker is focused if the stop is focused.
  • The marker is primary if any of the following are true:
    • the stop's route is focused.
    • the stop's route is hovered.
    • the plan is finished and no other route is focused.
    • the stop is not done, and no other route is focused, and no other stop is focused.
  • The marker is secondary if any of the following are true:
    • another route is focused.
    • another stop is focused.
    • the stop is done.

Marker size definition

A marker can have one of four different widths: 1 to 4, used depending on how much content needs to be shown inside the marker.

Width 1:

  • When there's just an icon, no digit (for example for the "excluded from route" pin).
  • When there are 1 or 2 digits, no icon (stops 1-99, with no other status).

Width 2:

  • When there are 3 digits and no icon (stops 99-999, with no other status).
  • When there's 1 digit plus an icon.

Width 3:

  • When there are 2 digits plus an icon.

Width 4:

  • When there are 3 digits plus an icon.

Marker content definition

  • The content of a marker can be:
    • symbol only
    • text only
    • text and symbol
  • Marker only contains text if stop is part of a route and is not a terminal location.
  • Terminal locations markers contain only a symbol.
  • The appropriate symbol is rendered following these rules:
    • (todo) If stop was deleted, use deleted symbol.
    • If stop was skipped, use unreachable symbol.
    • If stop was added after an optimization, use added symbol.
    • If stop was edited after an optimization, use edited symbol.
    • If stop is part of a route:
      • If stop is the start location, use start symbol.
      • If stop is the end location, use end symbol.
      • If stop delivery was attempted:
        • If unsuccessful, use failure symbol.
        • If successful and stop is focused, use success symbol.
        • If successful and stop is not focused, don't use a symbol.
      • If stop delivery was not attempted:
        • If stop has high priority, use asap symbol.
        • If stop is pickup, use pickup symbol.
    • If stop is not part of a route:
      • If stop has high priority, use asap symbol.
      • If stop is pickup, use pickup symbol.
      • Otherwise, use unoptimized symbol.

Any symbol listed above can be replaced by one of higher precedence.

For stops that are not a terminal location, the priority order of its symbol is:

Deleted > Unreachable > Added > Edited > Failure > Success > Issue > Pickup > ASAP

4.14.45

2 years ago

4.14.46

2 years ago

4.14.43

2 years ago

4.14.44

2 years ago

4.14.49

2 years ago

4.14.47

2 years ago

4.14.48

2 years ago

4.14.41

2 years ago

4.14.42

2 years ago

4.14.50

2 years ago

4.14.40

2 years ago

4.14.34

2 years ago

4.14.35

2 years ago

4.14.32

2 years ago

4.14.33

2 years ago

4.14.38

2 years ago

4.14.39

2 years ago

4.14.36

2 years ago

4.14.37

2 years ago

4.14.20-alpha.1

2 years ago

4.14.20-alpha.0

2 years ago

4.14.30

2 years ago

4.14.31

2 years ago

4.14.23

2 years ago

4.14.24

2 years ago

4.14.21

2 years ago

4.14.22

2 years ago

4.14.27

2 years ago

4.14.28

2 years ago

4.14.25

2 years ago

4.14.26

2 years ago

4.14.29

2 years ago

4.14.20

2 years ago

4.14.12

2 years ago

4.14.13

2 years ago

4.14.16

2 years ago

4.14.17

2 years ago

4.14.14

2 years ago

4.14.15

2 years ago

4.14.18

2 years ago

4.14.19

2 years ago

4.14.15-kiwi.0

2 years ago

4.14.16-kiwi.0

2 years ago

4.14.16-kiwi.1

2 years ago

4.14.12-kiwi.0

2 years ago

4.14.20-breno.0

2 years ago

4.14.15-alpha.0

2 years ago

4.14.11

2 years ago

4.14.5

2 years ago

4.14.6

2 years ago

4.14.7

2 years ago

4.14.8

2 years ago

4.14.1

2 years ago

4.14.2

2 years ago

4.14.3

2 years ago

4.14.4

2 years ago

4.9.4

2 years ago

4.9.3

2 years ago

4.14.9

2 years ago

4.9.0

2 years ago

4.9.2

2 years ago

4.9.1

2 years ago

4.12.5-alpha.0

2 years ago

4.14.0

2 years ago

4.13.6

2 years ago

4.13.7

2 years ago

4.13.8

2 years ago

4.13.9

2 years ago

4.13.2

2 years ago

4.13.3

2 years ago

4.13.4

2 years ago

4.13.5

2 years ago

4.8.1

2 years ago

4.8.0

2 years ago

4.8.3

2 years ago

4.8.2

2 years ago

4.14.10

2 years ago

4.7.0

2 years ago

4.13.0

2 years ago

4.13.1

2 years ago

4.7.1

2 years ago

4.6.2-alpha.0

2 years ago

4.6.1

2 years ago

4.6.0

2 years ago

4.13.11

2 years ago

4.13.12

2 years ago

4.13.10

2 years ago

4.13.13

2 years ago

4.6.6

2 years ago

4.6.3

2 years ago

4.6.2

2 years ago

4.6.5

2 years ago

4.6.4

2 years ago

4.12.22

2 years ago

4.12.21

2 years ago

4.12.20

2 years ago

4.12.24

2 years ago

4.12.23

2 years ago

4.5.2-map.8

2 years ago

4.12.11

2 years ago

4.12.10

2 years ago

4.12.15

2 years ago

4.12.14

2 years ago

4.12.13

2 years ago

4.12.12

2 years ago

4.12.19

2 years ago

4.12.18

2 years ago

4.12.17

2 years ago

4.12.16

2 years ago

4.10.0

2 years ago

4.12.7

2 years ago

4.11.10

2 years ago

4.12.8

2 years ago

4.12.9

2 years ago

4.12.23-alpha.0

2 years ago

4.12.3

2 years ago

4.12.4

2 years ago

4.12.5

2 years ago

4.12.6

2 years ago

4.11.11

2 years ago

4.12.23-alpha.1

2 years ago

4.12.0

2 years ago

4.12.1

2 years ago

4.12.2

2 years ago

4.11.8

2 years ago

4.11.9

2 years ago

4.11.4

2 years ago

4.11.5

2 years ago

4.11.6

2 years ago

4.11.7

2 years ago

4.11.0

2 years ago

4.11.1

2 years ago

4.11.2

2 years ago

4.11.3

2 years ago

4.3.21-potato.4

2 years ago

4.3.21-potato.5

2 years ago

4.3.21-potato.2

2 years ago

4.3.21-potato.3

2 years ago

4.3.21-potato.0

2 years ago

4.3.21-potato.1

2 years ago

4.3.21-potato.6

2 years ago

4.5.0

2 years ago

4.5.2

2 years ago

4.5.1

2 years ago

4.5.2-map.0

2 years ago

4.5.2-map.1

2 years ago

4.5.2-map.2

2 years ago

4.5.2-map.3

2 years ago

4.5.2-map.4

2 years ago

4.5.2-map.5

2 years ago

4.5.2-map.6

2 years ago

4.5.2-map.7

2 years ago

4.4.1

2 years ago

4.4.0

2 years ago

4.4.3

2 years ago

4.4.2

2 years ago

4.4.5-alpha.1

2 years ago

4.4.5-alpha.0

2 years ago

4.4.5-alpha.2

2 years ago

4.4.5

2 years ago

4.4.4

2 years ago

4.4.6

2 years ago

4.3.12-alpha.3

2 years ago

4.3.12-alpha.2

2 years ago

4.3.12-alpha.1

2 years ago

4.3.19-kiwi.0

2 years ago

4.3.21-kiwi.1

2 years ago

4.3.21-kiwi.0

2 years ago

4.3.17

2 years ago

4.3.16

2 years ago

4.3.15

2 years ago

4.3.14

2 years ago

4.3.19

2 years ago

4.3.18

2 years ago

4.3.20

2 years ago

4.3.21

2 years ago

4.3.12-alpha.0

2 years ago

4.3.9

2 years ago

4.3.13

2 years ago

4.3.12

2 years ago

4.3.11

2 years ago

4.3.10

2 years ago

4.2.28

2 years ago

4.2.29

2 years ago

4.2.26

2 years ago

4.2.27

2 years ago

4.3.2

2 years ago

4.3.1

2 years ago

4.3.4

2 years ago

4.3.3

2 years ago

4.3.0

2 years ago

4.3.6

2 years ago

4.3.5

2 years ago

4.3.7

2 years ago

4.2.31

2 years ago

4.2.32

2 years ago

4.2.30

2 years ago

4.2.20

2 years ago

4.2.21

2 years ago

4.2.22

2 years ago

4.2.23

2 years ago

4.2.24

2 years ago

4.2.25

2 years ago

4.2.10

2 years ago

4.2.11

2 years ago

4.2.12

2 years ago

4.2.17

2 years ago

4.2.18

2 years ago

4.2.19

2 years ago

4.2.13

2 years ago

4.2.14

2 years ago

4.2.15

2 years ago

4.2.16

2 years ago

4.2.3

2 years ago

4.2.2

2 years ago

4.2.5

2 years ago

4.2.4

2 years ago

4.2.1

2 years ago

4.2.0

2 years ago

4.2.7

2 years ago

4.2.6

2 years ago

4.2.9

2 years ago

4.2.8

2 years ago

4.1.4

2 years ago

4.1.6

2 years ago

4.1.5

2 years ago

4.1.3

2 years ago

4.1.2

2 years ago

4.1.1

2 years ago

4.1.0

2 years ago

4.0.3-kiwi.2

2 years ago

4.0.3-kiwi.1

2 years ago

4.0.3

2 years ago

4.0.3-kiwi.0

2 years ago

3.2.5-kiwi.2

2 years ago

4.0.2

2 years ago

4.0.0

2 years ago

3.2.5

2 years ago

3.2.5-kiwi.1

2 years ago

3.2.5-kiwi.0

2 years ago

3.2.4

2 years ago

3.2.4-alpha1.2

2 years ago

3.2.4-alpha1.0

2 years ago

3.2.3

2 years ago

3.2.3-alpha.1

2 years ago

3.2.3-alpha.0

2 years ago

3.2.2

2 years ago

3.2.1

2 years ago

3.2.0

2 years ago

3.1.0

2 years ago

3.0.3

2 years ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.1-alpha.1

2 years ago

3.0.1-alpha.0

2 years ago

3.0.0

2 years ago

2.2.7-alpha.7

2 years ago

2.2.7-alpha.6

2 years ago

2.2.7-alpha.5

2 years ago

2.2.7-alpha.4

2 years ago

2.2.7-alpha.3

2 years ago

2.2.7-alpha.2

2 years ago

2.2.7-alpha.1

2 years ago

2.2.2-alpha.13

2 years ago

2.2.2-alpha.12

2 years ago

2.2.2-alpha.10

2 years ago

2.2.6

2 years ago

2.2.5

2 years ago

2.2.2-alpha.9

2 years ago

2.2.2-alpha.7

2 years ago

2.2.2-alpha.6

2 years ago

2.2.4

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.1.17

2 years ago

2.1.16

2 years ago

2.1.15

2 years ago

2.1.14

2 years ago

2.1.13

2 years ago

2.1.12

2 years ago

2.1.11

2 years ago

2.1.10

2 years ago

2.1.9

2 years ago

2.1.8

2 years ago

2.1.7

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

2.0.0-21

2 years ago

2.0.0-20

2 years ago

2.0.0-19

2 years ago

1.0.4

2 years ago

2.0.0-18

2 years ago

2.0.0-17

2 years ago

2.0.0-16

2 years ago

2.0.0-15

2 years ago

2.0.0-14

2 years ago

2.0.0-13

2 years ago

2.0.0-12

2 years ago

2.0.0-11

2 years ago

2.0.0-10

2 years ago

2.0.0-9

2 years ago

2.0.0-8

2 years ago

2.0.0-7

2 years ago

2.0.0-6

2 years ago

2.0.0-5

2 years ago

2.0.0-4

2 years ago

2.0.0-3

2 years ago

2.0.0-2

2 years ago

2.0.0-1

2 years ago

2.0.0-0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.5.7

2 years ago

0.5.6

2 years ago

0.5.5

2 years ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.14

2 years ago

0.4.13

2 years ago

0.4.12

2 years ago

0.4.11

2 years ago

0.4.10

2 years ago

0.4.9

2 years ago

0.4.8

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.10

2 years ago

0.3.9

2 years ago

0.3.8

2 years ago

0.3.7

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.19

3 years ago

0.0.18

3 years ago

0.0.17

3 years ago

0.0.16

3 years ago

0.0.15

3 years ago

0.0.14

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago