1.20.32 • Published 3 days ago

@local-logic/sdks-js v1.20.32

Weekly downloads
-
License
-
Repository
-
Last release
3 days ago

Local Logic SDKs JS (Beta)

Local Logic SDKs JS provides access to the next generation of Local Logic web SDKs.

Getting started

Installation

First, install with yarn, pnpm, or npm:

yarn add @local-logic/sdks-js
pnpm add @local-logic/sdks-js
npm i --save @local-logic/sdks-js

The script is also available in umd and es format from the Local Logic CDN: https://sdk.locallogic.co/sdks-js/<VERSION>/index.<FORMAT>.js

Usage

You can now import LocalLogicSDK:

import LocalLogicSDK from "@local-logic/sdks-js";

const ll = LocalLogicSDK("<API_KEY>");

ℹ️ Your API_KEY should be provided to you by a Local Logic team member.

With the instance of LocalLogicSDK, you are now free to create new widgets:

// Code from previous step
// ...

/**
 * Create a container HTMLElement
 */
const container = document.createElement("div");
container.style.cssText = `
  height: 100vh;
  width: 100vw;
  display: flex;
`;
document.body.appendChild(container);

// Render Local Content into the container
ll.create("local-content", container, {
  lat: 45.52859,
  lng: -73.58785,
  marker: {
    lat: 45.52859,
    lng: -73.58785,
  },
});

Browser support

The SDKs are configured with Browserslist and @vitejs/plugin-legacy to support these browsers.

The SDKs will only serve polyfilled chunks only in legacy browsers without native ESM support. This keeps bundle sizes small for modern browsers.

API

LocalLogicSDK

LocalLogicSDK instance provides global config options and methods.

Options

LocalLogicSDK(apiKey, options)

NameRequiredTypeDefaultDescription
apiKeytruestringApiKey required for making requests to the Local Logic API.
options.appearancefalseAppearanceAPIThe appearance option provides theme and variable support customizing the look and feel of your widgets.
options.localefalse"en" \| "fr""en"The locale option specifies the language of the scores and the UI interface.

localLogicSDK.create

The create method is used to render new widget instances.

Options

localLogicSDK.create(sdkType, container, options, renderOptions)

NameRequiredTypeDefaultDescription
sdkTypetrue"local-content" \| "demographics"The SDK you would like to create.
containertrueHTMLElementThe element to render in to.
optionstrueobjectOptions required for te specified sdkType. Options for each SDK are detailed below.
options.lattruenumberInitial viewport latitude.
options.lngtruenumberInitial viewport longitude.
renderOptions.lazyfalsenumbertrueIf true, the SDK will only load content when it scrolls into the viewport.
"local-content" specific options
NameRequiredTypeDefaultDescription
zoomfalsenumber16Initial viewport zoom.
pitchfalsenumber0Initial viewport pitch.
bearingfalsenumber0Initial viewport bearing.
cooperativeGesturesfalsebooleantrueIf true, scroll zoom will require pressing the ctrl or key while scrolling to zoom map, and touch pan will require using two fingers while panning to move the map.
markerfalse{ lat: number; lng: number; icon?: "pin" \| "house" }If provided, will render Local Content using a pin marker. The marker can be used to symbolize a location being analyzed. This value is typically the same as the lat and lng.
distanceUnitfalse"metric" \| "imperial"metricPrimarily used for the commute calculator. Will display the distance in mi/yd under the imperial system or km/m under the metric system.
mapProviderfalse{ name: "maptiler" \| "google"; key?: string }{ name: "maptiler" }Desired map provider data; key is only required if name is set to "google".
"demographics" specific options
NameRequiredTypeDefaultDescription
titlefalseboolean \| string"Local Demographics"Setting the title to a string will replace the localized internal title. Setting the title to false will hide the title altogether. If you choose to set your own string, ensure you are sending the correct string when the locale changes.

localLogicSDK.on

The on method takes a callback which is triggered when create options when an event occurs.

Options

localLogicSDK.on(event, callback)

NameRequiredTypeDefaultDescription
eventtrue"change"The name of the event.
callbacktrue({ type: string, data: unknown })The callback to be triggered when the specified event occurs.

localLogicSDK.destroy

The destroy method is used to teardown the created SDK.

localLogicSDK.update

The update method is used to update the widget with new values. This can be useful when, for example, you want to change the widget location.

Options

localLogicSDK.update(options)

NameRequiredTypeDefaultDescription
options.lattruenumberInitial viewport latitude.
options.lngtruenumberInitial viewport longitude.
options.zoomfalsenumber16Initial viewport zoom.
options.pitchfalsenumberInitial viewport pitch.
options.bearingfalsenumberInitial viewport bearing.
options.cooperativeGesturesfalsebooleantrueIf true, scroll zoom will require pressing the ctrl or key while scrolling to zoom map, and touch pan will require using two fingers while panning to move the map.
options.markerfalse{ lat: number; lng: number; icon?: "pin" \| "house"}If provided, will render Local Content using a pin marker. The marker can be used to symbolize a location being analyzed. This value is typically the same as the lat and lng.
distanceUnitfalse"metric" \| "imperial"metricPrimarily used for the commute calculator. Will display the distance in mi/yd under the imperial system or km/m under the metric system.

TypeScript Support

Local Logic SDKs JS comes packaged with TypeScript declarations.

1.20.32

3 days ago

1.20.31

4 days ago

1.20.30

5 days ago

1.20.29

7 days ago

1.20.27

11 days ago

1.20.26

13 days ago

1.20.25

14 days ago

1.20.24

26 days ago

1.20.23

1 month ago

1.20.20

1 month ago

1.20.21

1 month ago

1.20.22

1 month ago

1.20.19

2 months ago

1.20.18

2 months ago

1.20.17

2 months ago

1.20.16

2 months ago

1.20.15

2 months ago

1.20.14

2 months ago

1.20.13

2 months ago

1.20.12

2 months ago

1.20.11

2 months ago

1.20.10

3 months ago

1.20.9

3 months ago

1.20.8

3 months ago

1.20.7

3 months ago

1.20.5

3 months ago

1.20.6

3 months ago

1.20.4

3 months ago

1.20.3

3 months ago

1.20.2

3 months ago

1.20.1

3 months ago

1.20.0

3 months ago

1.19.35

3 months ago

1.19.34

4 months ago

1.19.33

4 months ago

1.19.32

4 months ago

1.19.31

4 months ago

1.19.30

4 months ago

1.19.29

4 months ago

1.19.28

4 months ago

1.19.27

5 months ago

1.19.26

5 months ago

1.19.23

5 months ago

1.19.24

5 months ago

1.19.25

5 months ago

1.19.21

5 months ago

1.19.20

5 months ago

1.14.0

10 months ago

1.18.0

7 months ago

1.19.12

6 months ago

1.19.13

6 months ago

1.19.10

6 months ago

1.19.11

6 months ago

1.19.16

6 months ago

1.19.17

6 months ago

1.19.14

6 months ago

1.19.18

5 months ago

1.19.19

5 months ago

1.15.0

10 months ago

1.19.0

7 months ago

1.15.4

10 months ago

1.15.3

10 months ago

1.15.2

10 months ago

1.15.1

10 months ago

1.19.4

6 months ago

1.19.3

6 months ago

1.19.2

7 months ago

1.19.1

7 months ago

1.19.8

6 months ago

1.19.7

6 months ago

1.19.6

6 months ago

1.19.5

6 months ago

1.19.9

6 months ago

1.16.3

9 months ago

1.16.2

9 months ago

1.16.1

9 months ago

1.16.0

9 months ago

1.16.5

8 months ago

1.16.4

8 months ago

1.17.2

7 months ago

1.17.1

8 months ago

1.17.0

8 months ago

1.17.6

7 months ago

1.17.5

7 months ago

1.17.4

7 months ago

1.17.3

7 months ago

1.17.7

7 months ago

1.13.2

11 months ago

1.11.4

12 months ago

1.11.3

12 months ago

1.11.2

12 months ago

1.11.1

1 year ago

1.11.7

12 months ago

1.11.6

12 months ago

1.11.5

12 months ago

1.12.3

12 months ago

1.12.2

12 months ago

1.12.1

12 months ago

1.12.0

12 months ago

1.12.7

12 months ago

1.12.6

12 months ago

1.12.5

12 months ago

1.12.4

12 months ago

1.12.9

11 months ago

1.12.8

11 months ago

1.12.12

11 months ago

1.12.11

11 months ago

1.12.14

11 months ago

1.12.13

11 months ago

1.11.0

1 year ago

1.13.1

11 months ago

1.13.0

11 months ago

1.10.5

1 year ago

1.10.4

1 year ago

1.10.3

1 year ago

1.10.2

1 year ago

1.10.9

1 year ago

1.10.8

1 year ago

1.10.7

1 year ago

1.10.6

1 year ago

1.6.4

1 year ago

1.6.3

1 year ago

2.0.0

1 year ago

1.9.0

1 year ago

1.6.8

1 year ago

1.6.7

1 year ago

1.6.6

1 year ago

1.6.5

1 year ago

1.10.1

1 year ago

1.10.0

1 year ago

1.8.2

1 year ago

1.8.1

1 year ago

1.8.0

1 year ago

1.7.2

1 year ago

1.7.1

1 year ago

1.7.0

1 year ago

2.1.0

1 year ago

1.2.0

1 year ago

1.0.0

1 year ago

1.6.2

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.4.0

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.0.0-beta.66

1 year ago

1.0.0-beta.67

1 year ago

1.0.0-beta.64

1 year ago

1.0.0-beta.65

1 year ago

1.0.0-beta.62

1 year ago

1.0.0-beta.63

1 year ago

1.0.0-beta.61

2 years ago

1.0.0-beta.68

1 year ago

1.0.0-beta.69

1 year ago

1.1.0

1 year ago

1.5.2

1 year ago

1.5.1

1 year ago

1.3.3

1 year ago

1.5.0

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.0.0-beta.60

2 years ago

1.0.0-beta.55

2 years ago

1.0.0-beta.56

2 years ago

1.0.0-beta.53

2 years ago

1.0.0-beta.54

2 years ago

1.0.0-beta.51

2 years ago

1.0.0-beta.52

2 years ago

1.0.0-beta.50

2 years ago

1.0.0-beta.59

2 years ago

1.0.0-beta.57

2 years ago

1.0.0-beta.58

2 years ago

1.0.0-beta.44

2 years ago

1.0.0-beta.45

2 years ago

1.0.0-beta.42

2 years ago

1.0.0-beta.43

2 years ago

1.0.0-beta.40

2 years ago

1.0.0-beta.41

2 years ago

1.0.0-beta.48

2 years ago

1.0.0-beta.49

2 years ago

1.0.0-beta.46

2 years ago

1.0.0-beta.47

2 years ago

1.0.0-beta.33

2 years ago

1.0.0-beta.34

2 years ago

1.0.0-beta.39

2 years ago

1.0.0-beta.37

2 years ago

1.0.0-beta.38

2 years ago

1.0.0-beta.35

2 years ago

1.0.0-beta.36

2 years ago

1.0.0-beta.32

2 years ago

1.0.0-beta.31

2 years ago

1.0.0-beta.30

2 years ago

1.0.0-beta.29

2 years ago

1.0.0-beta.28

2 years ago

1.0.0-beta.27

2 years ago

1.0.0-beta.26

2 years ago

1.0.0-beta.25

2 years ago

1.0.0-beta.24

2 years ago

1.0.0-beta.23

2 years ago

1.0.0-beta.22

2 years ago

1.0.0-beta.21

2 years ago

1.0.0-beta.20

2 years ago

1.0.0-beta.19

2 years ago

1.0.0-beta.18

2 years ago

1.0.0-beta.17

2 years ago

1.0.0-beta.16

2 years ago

1.0.0-beta.15

2 years ago

1.0.0-beta.14

2 years ago

1.0.0-beta.13

2 years ago

1.0.0-beta.12

2 years ago

1.0.0-beta.11

2 years ago

1.0.0-beta.10

2 years ago

1.0.0-beta.9

2 years ago

1.0.0-beta.8

2 years ago

1.0.0-beta.7

2 years ago

1.0.0-beta.6

2 years ago

1.0.0-beta.5

2 years ago

1.0.0-beta.4

2 years ago

1.0.0-beta.3

2 years ago

1.0.0-beta.2

2 years ago

1.0.0-beta.1

2 years ago