@jibestream-dev/jmap-zone-kit
Kit for the Jibestream SDK to utilize Zones plotted in the CMS
Last updated 2 years ago by daveleitch .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @jibestream-dev/jmap-zone-kit 
SYNC missed versions from official npm registry.

Classes

Zone
ZoneCollectionjmap.core.BaseCollection

Class representing a collection of Devices.

ZoneKit

Kit for working with Jibestream Zones

Zone

Kind: global class

new Zone()

Class representing a Zone

zone.name : String

Kind: instance property of Zone

zone.description : String

Kind: instance property of Zone

zone.color : String

Kind: instance property of Zone

ZoneCollection ⇐ jmap.core.BaseCollection

Class representing a collection of Devices.

Kind: global class
Extends: jmap.core.BaseCollection

new ZoneCollection()

Create a collection of Devices.

zoneCollection.isZone(item) ⇒ Boolean

Returns a boolean for whather or not argument is constructed as an Device object

Kind: instance method of ZoneCollection
Returns: Boolean - Boolean based on evaluation result

Param Type Description
item Object Item to evaluate

zoneCollection.getByName(name) ⇒ Array.<Zone>

  • Returns Zone/s by their name (or returns an empty array)

Kind: instance method of ZoneCollection
Returns: Array.<Zone> - - The desired Zone/s (or an empty array if name is invalid)
Access: public

Param Type Description
name string The name of the desired Zone/s

Example

const name = 'Food Court'
const zone = e(name)

zoneCollection.getByWaypoint(waypoint) ⇒ Array.<Zone>

  • Returns Zone/s by a given waypoint (or returns an empty array)

Kind: instance method of ZoneCollection
Returns: Array.<Zone> - - The desired Zone/s (or an empty array if waypoint is invalid)
Access: public

Param Type Description
waypoint Waypoint The waypoint to search with

Example

const waypoint = control.currentMap.waypoints[0]
const zone = getByWaypoint(waypoint)

zoneCollection.getByMap(map) ⇒ Array.<Zone>

  • Returns Zone/s by a given map (or returns an empty array)

Kind: instance method of ZoneCollection
Returns: Array.<Zone> - - The desired Zone/s (or an empty array if map is invalid)
Access: public

Param Type Description
map Map The map on which we're searching

Example

const map = control.currentMap
const zone = getByMap(map)

ZoneKit

Kit for working with Jibestream Zones

Kind: global class

new ZoneKit(core, control)

Create a ZoneKit.

Param Type Description
core jmap.core instantiated JCore
control jmap.JController instantiated JController

zoneKit.getWaypointsInZone(zone) ⇒ Array.<jmap.core.Waypoint>

  • Returns all waypoints associated with a given Zone (or returns an empty array)

Kind: instance method of ZoneKit
Returns: Array.<jmap.core.Waypoint> - - The waypoints associated with a given zone (or an empty array)
Access: public

Param Type Description
zone Zone The Zone we're using to search for waypoints

Example

const zone = zoneKit.zones.getAll()[0]
const waypoints = zoneKit.getWaypointsInZone(zone)

zoneKit.getDestinationsInZone(zone) ⇒ Array.<jmap.core.Destination>

  • Returns all destinations associated with waypoints within an zone (or returns an empty array)

Kind: instance method of ZoneKit
Returns: Array.<jmap.core.Destination> - - The destinations associated with a given zone (or an empty array)
Access: public

Param Type Description
zone Zone The Zone we're using to search for destinations

Example

const zone = zoneKit.zones.getAll()[0]
const destinations = zoneKit.getDestinationsInZone(zone)

zoneKit.getAmenitiesInZone(zone) ⇒ Array.<jmap.core.Amentity>

  • Returns all amenity instances associated with waypoints within an zone (or returns an empty array)

Kind: instance method of ZoneKit
Returns: Array.<jmap.core.Amentity> - - The amenities associated with a given zone (or an empty array)
Access: public

Param Type Description
zone Zone The Zone we're using to search for destinations

Example

const zone = zoneKit.zones.getAll()[0]
const amentities = zoneKit.getAmenitiesInZone(zone)

zoneKit.getBoundsOfZoneOnMap(zone, map) ⇒ jmap.Bounds

  • For a given Zone, return the bounding box for the associated waypoints on the specified map If an invalid zone or map is given, null is returned

Kind: instance method of ZoneKit
Returns: jmap.Bounds - - A Bounds object
Access: public

Param Type Description
zone Zone The Zone we're using to calculate bounding boxes
map jmap.core.Map The map we'll use to calculate the bounding box

Example

const zone = zoneKit.zones.getAll()[0]
const map = control.currentMap
const bounds = zoneKit.getBoundsOfZone(zone, map)

zoneKit.getPolygonOfZoneOnMap(zone, map) ⇒ jmap.jungle.shape.Polygon

  • Returns a polygon shape, based on the waypoints associated with the specified zone on the specified map. The zone must have three or more waypoints associated with it on the given map, otherwise null will be returned

Kind: instance method of ZoneKit
Returns: jmap.jungle.shape.Polygon - - A Polygon object
Access: public

Param Type Description
zone Zone The Zone we're using to calculate polygons
map jmap.core.Map The map we'll use to calculate the polygon

Example

const zone = zoneKit.zones.getAll()[0]
const map = control.currentMap
const polygon = zoneKit.getPolygonOfZone(zone, map)

zoneKit.drawPolygonOfZoneOnMap(zone, map, style) ⇒ Polygon

  • Given a specific Zone, draw a polygon the encompasses all of its waypoints on the specified map

Kind: instance method of ZoneKit
Returns: Polygon - - The polygon that was drawn
Access: public

Param Type Description
zone Zone The Zone we wish to highlight using a polygon
map jmap.core.Map The map we wish to draw the polygon on
style jmap.Style The way in which the polygon should be styled. Default style uses zone.color

Example

const zone = zoneKit.zones.getAll()[0]
const map = control.currentMap
const polygon = zoneKit.drawPolygonOfZone(zone, map)

zoneKit.getZones([cb]) ⇒ ZoneKit

  • Returns all zones for the currently loaded building

Kind: instance method of ZoneKit
Returns: ZoneKit - - The current ZoneKit instance
Access: public

Param Type Description
[cb] function The callback function, which will run once the Zones have been retrieved. The Zones will be stored in this.zones

Example

const fn = (error, zones) => console.log(zones)
zoneKit.getZones(fn)

zoneKit.getCentroidOfZoneOnMap(zone, map) ⇒ Array.<Number>

  • Return the coordinates of the centroid of a given zone on the given map The zone must have three or more waypoints associated with it on the given map otherwise null will be returned

Kind: instance method of ZoneKit
Returns: Array.<Number> - - The centroid in the form of [x, y]
Access: public

Param Type Description
zone Zone The zone we wish to find the centroid of
map jmap.core.Map The map on which we'll use to find the centroid

Example

const zone = zoneKit.zones.getAll()[0]
const map = control.currentMap
const centroid = zoneKit.getCentroidOfZone(zone, map)

zoneKit.getClosestWaypointInZoneToPoint(zone, jMapPoint, [searchType]) ⇒ jmap.core.Waypoint

  • Given a specific point on the a map, return the closest waypoint associated with the given Zone

Kind: instance method of ZoneKit
Returns: jmap.core.Waypoint - - The closest waypoint within the specified Zone to the provided point
Access: public

Param Type Default Description
zone Zone The zone we wish to search within
jMapPoint jMapPoint The point we wish to search with
[searchType] String 'proximity' Either 'proximity' or 'grid'

Example

const jMapPoint = { x: 2750, y: 2750, mapId: control.currentMap.id }
const zone = zoneKit.zones.getAll()[0]
const waypoint = zoneKit.getClosestWaypointInZoneToPoint(zone, jMapPoint)

zoneKit.highlightUnitsInZone(zone, style) ⇒ ZoneKit

  • Highlight all units associated to a specific zone using either the color specified in the CMS or the color override provided

Kind: instance method of ZoneKit
Returns: ZoneKit - - The current ZoneKit instance
Access: public

Param Type Description
zone Zone The zone we wish to highlight
style jmap.Style The way in which the unit will be styled

Example

const zone = zoneKit.zones.getAll()[0]
const style = new jmap.Style({ fill: '#4a85e2' })
zoneKit.highlightUnitsInZone(zone, style)

zoneKit.watchMovingObjects(zonesExitedCallback, zonesEnteredCallback) ⇒ ZoneKit

  • Subscribe to animation complete callback for moving objects and send back zones exited/entered

Kind: instance method of ZoneKit
Returns: ZoneKit - - The current ZoneKit instance
Access: public

Param Type Description
zonesExitedCallback function Callback for zones being exited
zonesEnteredCallback function Callback for zones being entered

Example

function watchMovingObjCallback(zones) {
}
zoneKit.watchMovingObjects(watchMovingObjCallback, watchMovingObjCallback)

zoneKit.unwatchMovingObjects() ⇒ ZoneKit

  • Unsubscribe to animation complete callback for moving objects

Kind: instance method of ZoneKit
Returns: ZoneKit - - The current ZoneKit instance
Access: public
Example

zonKit.unwatchMovingObjects()

Current Tags

  • 1.0.4                                ...           latest (2 years ago)

3 Versions

  • 1.0.4                                ...           2 years ago
  • 1.0.2                                ...           3 years ago
  • 1.0.1                                ...           3 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 4
Last Month 6
Dependencies (0)
None
Dev Dependencies (16)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |