1.4.8 • Published 2 years ago

dgtek-portal-map-package v1.4.8

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

dgtek-portal-map-package

:clipboard: Installation

yarn add dgtek-portal-map-package && mv node_modules/dgtek-portal-map-package/dist/map.worker.js public

or

npm install dgtek-portal-map-package && mv node_modules/dgtek-portal-map-package/dist/map.worker.js public

:clipboard: How to use

:page_with_curl: Configuring web-worker

You need to start web-worker.

Import the module startWorker from package:

import { startWorker } from 'dgtek-portal-map-package/dist/start-worker'

and then start the worker:

const worker = startWorker(publicPath, apiHost, apiAccessKey, credentials, role, callback)
  • publicPath is the path worker will be started from (required)
  • apiHost is the backend API url (for example https://dgtek-staging.herokuapp.com) (required)
  • apiAccessKey is needed to access backend API (required)
  • credentials user credentials (required)
  • role - user role (optional)
  • callback - your function that will receive the message when web-worker will be ready to work (optional)

:page_with_curl: Methods

After the worker will be created you can use it's methods to access the data

Each method receive callback to return the result (your function )

• refresh(callback)
• getBuildingsListForTable(status, callback) /* available status: lit, footprint, build, soon, other */
• getBuildingsList(status, callback) /* available status: lit, footprint, build, soon, other */
• getBuildingsByList(list, callback) /* list - array of buildings id */
• getMasterBuildingsList(callback) /* lit only */
• getSlavesForMaster(masterId, callback)
• getBuildingDetailsById(buildingId, callback) /* callback will receive building details */
• getBuildingDetailsByAddress(address, callback) /* callback will receive building details */
• createNewBuilding(data, callback) /* callback will receive the id of created building */
• deleteBuilding(buildingId, callback)
• patchBuildingDetails(buildingId, data, callback)
• putBuildingDetails(buildingId, data, callback)

☕ Example

const callback = data => console.log(data)

worker.getBuildingsList('lit', callback)

:memo: Package

Import package:

import DgtekMap from 'dgtek-portal-map-package'

Create container for map with id "container-for-map" and stylize it as you need:

<style>
  #container-for-map {
    position: relative;
    width: 70%;
    height: 70vh;
    margin: auto;
  }
  @media screen and (max-width: 600px) {
    #container-for-map {
      width: 100%;
    }
  }
</style>
<main>
  <figure id="container-for-map"></figure>
</main>

:clipboard: Get started

const map = new DGtekMap({
  container,
  center: { lat: -37.8357725, lng: 144.9738764 }
})

:clipboard: Catch search event

To receive the result of user input you should set the property searchCallback of worker:

worker.searchCallback = function (data) {
  console.log('SEARCH CALLBACK DATA:\n', data)
}
1.4.5

2 years ago

1.4.4

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.5

2 years ago

1.4.8

2 years ago

1.4.7

2 years ago

1.2.0

2 years ago

1.2.8

2 years ago

1.1.9

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.3.1

2 years ago

1.2.2

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.2.81

2 years ago

1.2.84

2 years ago

1.2.89

2 years ago

1.2.87

2 years ago

1.2.88

2 years ago

1.2.9

2 years ago

1.1.89

2 years ago

1.1.88

2 years ago

1.1.85

2 years ago

1.1.87

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.81

2 years ago

1.1.84

2 years ago

1.1.1

2 years ago

1.1.4

2 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.84

3 years ago

1.0.82

3 years ago

1.0.81

3 years ago

1.0.87

3 years ago

1.0.85

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago