@situm/cordova 3.4.4 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+
2
+
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "..": {
70
70
  "name": "@situm/cordova",
71
- "version": "3.3.3",
71
+ "version": "3.4.2",
72
72
  "engines": [
73
73
  {
74
74
  "name": "cordova-android",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@situm/cordova",
3
- "version": "3.4.4",
3
+ "version": "3.5.0",
4
4
  "description": "Situm Wayfinding for Capacitor and Cordova. Integrate plug&play indoor navigation experience with floorplans, POIs, routes and turn-by-turn directions in no time. With the power of Situm.",
5
5
  "private": false,
6
6
  "repository": "https://github.com/situmtech/cordova",
package/plugin.xml CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
4
  id="@situm/cordova"
5
- version="3.4.4">
5
+ version="3.5.0">
6
6
  <name>Situm Cordova plugin Official</name>
7
7
  <description>This is the stable branch.</description>
8
8
  <license>MIT</license>
@@ -89,7 +89,7 @@
89
89
  <config>
90
90
  </config>
91
91
  <pods use-frameworks="false">
92
- <pod name="SitumSDK" spec="~> 3.9.0"/>
92
+ <pod name="SitumSDK" spec="~> 3.10.0"/>
93
93
  </pods>
94
94
  </podspec>
95
95
 
@@ -106,10 +106,16 @@ public class PluginHelper {
106
106
  nmInstance = navigationManager;
107
107
  }
108
108
 
109
+ public void getDeviceId(CordovaInterface cordova, CordovaWebView webView, JSONArray args,
110
+ final CallbackContext callbackContext) {
111
+ String deviceId = String.valueOf(SitumSdk.getDeviceID());
112
+ callbackContext.sendPluginResult(new PluginResult(Status.OK, deviceId));
113
+ }
114
+
109
115
  public void fetchBuildings(CordovaInterface cordova, CordovaWebView webView, JSONArray args,
110
116
  final CallbackContext callbackContext) {
111
117
  try {
112
- getCommunicationManagerInstance().fetchBuildings(new Handler<Collection<Building>>() {
118
+ getCommunicationManagerInstance().fetchBuildings(new Handler<Collection<Building>>() {
113
119
  public void onSuccess(Collection<Building> buildings) {
114
120
  try {
115
121
  Log.d(PluginHelper.TAG, "onSuccess: Buildings fetched successfully.");
@@ -20,6 +20,7 @@ import java.util.Collection;
20
20
  import java.util.List;
21
21
  import java.util.Locale;
22
22
  import java.util.Map;
23
+ import java.util.Arrays;
23
24
 
24
25
  import es.situm.sdk.directions.DirectionsRequest;
25
26
  import es.situm.sdk.location.LocationRequest;
@@ -216,6 +217,8 @@ class SitumMapper {
216
217
  public static final String UPDATED_AT = "updatedAt";
217
218
  public static final String NAME = "name";
218
219
  public static final String ACCESSIBILITY_MODE = "accessibilityMode";
220
+ public static final String INCLUDED_TAGS = "includedTags";
221
+ public static final String EXCLUDED_TAGS = "excludedTags";
219
222
  public static final String POLYGON_POINTS = "polygonPoints";
220
223
  public static final String CODE = "code";
221
224
  public static final String BUILDING = "building";
@@ -926,8 +929,25 @@ static JSONObject buildingInfoToJsonObject(BuildingInfo buildingInfo) throws JSO
926
929
  DirectionsRequest.AccessibilityMode accessibilityMode = DirectionsRequest.AccessibilityMode.CHOOSE_SHORTEST;
927
930
  Boolean minimizeFloorChanges = false;
928
931
  double startingAngle = 0.0;
932
+ List<String> includedTags = null;
933
+ List<String> excludedTags = null;
929
934
 
930
935
  if ( joOptions != null) {
936
+ if (joOptions.has(SitumMapper.INCLUDED_TAGS) && joOptions.get(SitumMapper.INCLUDED_TAGS) != null) {
937
+ includedTags = new ArrayList<String>();
938
+ JSONArray jsonArray = joOptions.getJSONArray(SitumMapper.INCLUDED_TAGS);
939
+ for (int i = 0; i < jsonArray.length(); i++) {
940
+ includedTags.add(jsonArray.get(i).toString());
941
+ }
942
+ }
943
+
944
+ if (joOptions.has(SitumMapper.EXCLUDED_TAGS) && joOptions.get(SitumMapper.EXCLUDED_TAGS) != null) {
945
+ excludedTags = new ArrayList<String>();
946
+ JSONArray jsonArray = joOptions.getJSONArray(SitumMapper.EXCLUDED_TAGS);
947
+ for (int i = 0; i < jsonArray.length(); i++) {
948
+ excludedTags.add(jsonArray.get(i).toString());
949
+ }
950
+ }
931
951
  if (joOptions.has(SitumMapper.ACCESSIBILITY_MODE)) {
932
952
  String mode = joOptions.getString(SitumMapper.ACCESSIBILITY_MODE);
933
953
  if (mode.equals(DirectionsRequest.AccessibilityMode.ONLY_ACCESSIBLE.name())) {
@@ -947,6 +967,6 @@ static JSONObject buildingInfoToJsonObject(BuildingInfo buildingInfo) throws JSO
947
967
  minimizeFloorChanges = joOptions.getBoolean(SitumMapper.MINIMIZE_FLOOR_CHANGES);
948
968
  }
949
969
  }
950
- return new DirectionsRequest.Builder().from(from, Angle.fromDegrees(startingAngle)).to(to).accessibilityMode(accessibilityMode).minimizeFloorChanges(minimizeFloorChanges).build();
970
+ return new DirectionsRequest.Builder().from(from, Angle.fromDegrees(startingAngle)).to(to).accessibilityMode(accessibilityMode).minimizeFloorChanges(minimizeFloorChanges).includedTags(includedTags).excludedTags(excludedTags).build();
951
971
  }
952
972
  }
@@ -56,6 +56,8 @@ public class SitumPlugin extends CordovaPlugin {
56
56
  Integer cacheAge = args.getInt(0);
57
57
  Log.d(TAG,"Setting cache max age to " + cacheAge + " seconds");
58
58
  es.situm.sdk.SitumSdk.configuration().setCacheMaxAge(cacheAge, TimeUnit.SECONDS);
59
+ } else if (action.equalsIgnoreCase("getDeviceId")) {
60
+ getPluginInstance().getDeviceId(cordova, webView, args, callbackContext);
59
61
  } else if (action.equalsIgnoreCase("fetchBuildings")) {
60
62
  getPluginInstance().fetchBuildings(cordova, webView, args, callbackContext);
61
63
  } else if (action.equalsIgnoreCase("fetchBuildingInfo")) {
package/src/ios/Podfile CHANGED
@@ -1,5 +1,5 @@
1
1
  target 'SitumCordovaPlugin' do
2
2
  use_frameworks!
3
3
  platform :ios, '9.0'
4
- pod 'SitumSDK', '3.9.0'
4
+ pod 'SitumSDK', '3.10.0'
5
5
  end
@@ -691,6 +691,8 @@ static SitumLocationWrapper *singletonSitumLocationWrapperObj;
691
691
  NSNumber *accessible;
692
692
  BOOL minimizeFloorChanges = false;
693
693
  NSString *accessibilityModeValue = nil;
694
+ NSArray *includedTags = nil;
695
+ NSArray *excludedTags = nil;
694
696
  if(options) {
695
697
  accessible = (NSNumber*)[options valueForKey: @"accessible"];
696
698
  if (accessible == nil) {
@@ -698,6 +700,15 @@ static SitumLocationWrapper *singletonSitumLocationWrapperObj;
698
700
  }
699
701
  accessibilityModeValue = options[@"accessibilityMode"];
700
702
  minimizeFloorChanges = [(NSNumber*)[options valueForKey: @"minimizeFloorChanges"] boolValue];
703
+
704
+ if (options[@"includedTags"] != nil && ![options[@"includedTags"] isEqual:[NSNull null]]) {
705
+ includedTags = options[@"includedTags"];
706
+ [directionsRequest setIncludedTags:includedTags];
707
+ }
708
+ if (options[@"excludedTags"] != nil && ![options[@"excludedTags"] isEqual:[NSNull null]]) {
709
+ excludedTags = options[@"excludedTags"];
710
+ [directionsRequest setExcludedTags:excludedTags];
711
+ }
701
712
  }
702
713
 
703
714
  if (accessibilityModeValue != nil) {
@@ -17,6 +17,7 @@
17
17
  // The hooks for our plugin commands
18
18
  - (void)setApiKey:(CDVInvokedUrlCommand *)command;
19
19
  - (void)setUserPass:(CDVInvokedUrlCommand *)command;
20
+ - (void)getDeviceId:(CDVInvokedUrlCommand *)command;
20
21
  - (void)startPositioning:(CDVInvokedUrlCommand *)command;
21
22
  - (void)setUseRemoteConfig:(CDVInvokedUrlCommand *)command;
22
23
  - (void)stopPositioning:(CDVInvokedUrlCommand *)command;
@@ -62,6 +62,11 @@ static NSString *DEFAULT_SITUM_LOG = @"SitumSDK >>: ";
62
62
  }
63
63
  }
64
64
 
65
+ -(void)getDeviceId:(CDVInvokedUrlCommand *)command {
66
+ CDVPluginResult *pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[SITServices deviceID]];
67
+ [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
68
+ }
69
+
65
70
  - (void)fetchBuildingInfo:(CDVInvokedUrlCommand *)command
66
71
  {
67
72
  // TODO:
package/www/Interfaces.js CHANGED
@@ -31,9 +31,9 @@ var Building = {
31
31
  rotation,
32
32
  userIdentifier,
33
33
  customFields
34
- }
34
+ };
35
35
 
36
- module.exports = Building
36
+ module.exports = Building;
37
37
 
38
38
  /** @name
39
39
  * BuildingInfo
@@ -52,9 +52,9 @@ var BuildingInfo = {
52
52
  indoorPois,
53
53
  outdoorPois,
54
54
  events
55
- }
55
+ };
56
56
 
57
- module.exports = BuildingInfo
57
+ module.exports = BuildingInfo;
58
58
 
59
59
  /**
60
60
  * @name
@@ -77,9 +77,9 @@ var Floor = {
77
77
  mapUrl,
78
78
  scale,
79
79
  floorIdentifier
80
- }
80
+ };
81
81
 
82
- module.exports = Floor
82
+ module.exports = Floor;
83
83
 
84
84
  /** @name
85
85
  * Dimensions
@@ -92,9 +92,9 @@ module.exports = Floor
92
92
  var Dimensions = {
93
93
  width,
94
94
  height
95
- }
95
+ };
96
96
 
97
- module.exports = Dimensions
97
+ module.exports = Dimensions;
98
98
 
99
99
  /** @name
100
100
  * Bounds
@@ -111,9 +111,9 @@ var Bounds = {
111
111
  northWest,
112
112
  southEast,
113
113
  southWest
114
- }
114
+ };
115
115
 
116
- module.exports = Bounds
116
+ module.exports = Bounds;
117
117
 
118
118
  /**
119
119
  * @name
@@ -127,9 +127,9 @@ module.exports = Bounds
127
127
  var Coordinate = {
128
128
  latitude,
129
129
  longitude
130
- }
130
+ };
131
131
 
132
- module.exports = Coordinate
132
+ module.exports = Coordinate;
133
133
 
134
134
  /**
135
135
  * @name
@@ -143,9 +143,9 @@ module.exports = Coordinate
143
143
  var CartesianCoordinate = {
144
144
  x,
145
145
  y
146
- }
146
+ };
147
147
 
148
- module.exports = CartesianCoordinate
148
+ module.exports = CartesianCoordinate;
149
149
 
150
150
  /**
151
151
  * @name
@@ -179,9 +179,9 @@ var Poi = {
179
179
  category,
180
180
  infoHtml,
181
181
  customFields
182
- }
182
+ };
183
183
 
184
- module.exports = Poi
184
+ module.exports = Poi;
185
185
 
186
186
  /**
187
187
  * @name
@@ -204,9 +204,9 @@ var Geofence = {
204
204
  infoHtml,
205
205
  polygonPoints,
206
206
  customFields
207
- }
207
+ };
208
208
 
209
- module.exports = Geofence
209
+ module.exports = Geofence;
210
210
 
211
211
  /**
212
212
  * @name
@@ -220,16 +220,15 @@ module.exports = Geofence
220
220
  * @property {boolean} public - Whether the category is public or not
221
221
  */
222
222
 
223
-
224
223
  var PoiCategory = {
225
224
  poiCategoryCode,
226
225
  poiCategoryName,
227
226
  icon_selected,
228
227
  icon_unselected,
229
228
  public
230
- }
229
+ };
231
230
 
232
- module.exports = PoiCategory
231
+ module.exports = PoiCategory;
233
232
 
234
233
  /**
235
234
  * @name
@@ -251,9 +250,9 @@ var Point = {
251
250
  floorIdentifier,
252
251
  isIndoor,
253
252
  isOutdoor
254
- }
253
+ };
255
254
 
256
- module.exports = Point
255
+ module.exports = Point;
257
256
 
258
257
  /**
259
258
  * @name
@@ -297,9 +296,9 @@ var Location = {
297
296
  isIndoor,
298
297
  isOutdoor,
299
298
  deviceId
300
- }
299
+ };
301
300
 
302
- module.exports = Location
301
+ module.exports = Location;
303
302
 
304
303
  /**
305
304
  * @name
@@ -313,9 +312,9 @@ module.exports = Location
313
312
  var LocationStatus = {
314
313
  statusName,
315
314
  statusOrdinal
316
- }
315
+ };
317
316
 
318
- module.exports = LocationStatus
317
+ module.exports = LocationStatus;
319
318
 
320
319
  /**
321
320
  * @name
@@ -333,9 +332,9 @@ var Angle = {
333
332
  degreesClockwise,
334
333
  radians,
335
334
  radiansMinusPiPi
336
- }
335
+ };
337
336
 
338
- module.exports = Angle
337
+ module.exports = Angle;
339
338
 
340
339
  /**
341
340
  * @name
@@ -365,9 +364,9 @@ var Route = {
365
364
  to,
366
365
  steps,
367
366
  segments
368
- }
367
+ };
369
368
 
370
- module.exports = Route
369
+ module.exports = Route;
371
370
 
372
371
  /**
373
372
  * @name
@@ -391,9 +390,9 @@ var RouteStep = {
391
390
  to,
392
391
  isFirst,
393
392
  isLast
394
- }
393
+ };
395
394
 
396
- module.exports = RouteStep
395
+ module.exports = RouteStep;
397
396
 
398
397
  /**
399
398
  * @name
@@ -407,9 +406,9 @@ module.exports = RouteStep
407
406
  var RouteSegment = {
408
407
  floorIdentifier,
409
408
  points
410
- }
409
+ };
411
410
 
412
- module.exports = RouteSegment
411
+ module.exports = RouteSegment;
413
412
 
414
413
  /**
415
414
  * @name
@@ -435,10 +434,9 @@ var Indication = {
435
434
  stepIdxDestination,
436
435
  stepIdxOrigin,
437
436
  neededLevelChange
438
- }
439
-
440
- module.exports = Indication
437
+ };
441
438
 
439
+ module.exports = Indication;
442
440
 
443
441
  /**
444
442
  * @name
@@ -474,10 +472,9 @@ var NavigationProgress = {
474
472
  routeStep,
475
473
  points,
476
474
  segments
477
- }
478
-
479
- module.exports = NavigationProgress
475
+ };
480
476
 
477
+ module.exports = NavigationProgress;
481
478
 
482
479
  /**
483
480
  * @name
@@ -509,9 +506,9 @@ var SitumEvent = {
509
506
  name,
510
507
  x,
511
508
  y
512
- }
509
+ };
513
510
 
514
- module.exports = SitumEvent
511
+ module.exports = SitumEvent;
515
512
 
516
513
  /**
517
514
  * @name
@@ -530,10 +527,10 @@ var SitumConversionArea = {
530
527
  topLeft,
531
528
  topRight,
532
529
  bottomLeft,
533
- bottomRight,
534
- }
530
+ bottomRight
531
+ };
535
532
 
536
- module.exports = Circle
533
+ module.exports = Circle;
537
534
 
538
535
  /**
539
536
  * @name
@@ -546,10 +543,10 @@ module.exports = Circle
546
543
 
547
544
  var Circle = {
548
545
  center,
549
- radius,
550
- }
546
+ radius
547
+ };
551
548
 
552
- module.exports = SitumConversionArea
549
+ module.exports = SitumConversionArea;
553
550
 
554
551
  /**
555
552
  * @name
@@ -587,7 +584,7 @@ var LocationRequest = {
587
584
  beaconFilters,
588
585
  smallestDisplacement,
589
586
  realtimeUpdateInterval,
590
- autoEnableBleDuringPositioning,
587
+ autoEnableBleDuringPositioning
591
588
  };
592
589
 
593
590
  module.exports = LocationRequest;
@@ -601,7 +598,7 @@ module.exports = LocationRequest;
601
598
  */
602
599
  var LocationOptions = LocationRequest;
603
600
 
604
- module.exports = LocationOptions
601
+ module.exports = LocationOptions;
605
602
 
606
603
  /**
607
604
  * @name
@@ -629,9 +626,9 @@ var NavigationRequest = {
629
626
  timeToFirstIndication,
630
627
  roundIndicationsStep,
631
628
  timeToIgnoreUnexpectedFloorChanges
632
- }
629
+ };
633
630
 
634
- module.exports = NavigationRequest
631
+ module.exports = NavigationRequest;
635
632
 
636
633
  /**
637
634
  * @name
@@ -649,9 +646,9 @@ var DirectionsRequest = {
649
646
  from,
650
647
  to,
651
648
  options
652
- }
649
+ };
653
650
 
654
- module.exports = DirectionsRequest
651
+ module.exports = DirectionsRequest;
655
652
 
656
653
  /**
657
654
  * @name
@@ -663,15 +660,19 @@ module.exports = DirectionsRequest
663
660
  * @property {boolean} accessible - Defines wheter or not the route has to be suitable for wheel chairs (true) or not (false). @deprecated, use accessibilityMode
664
661
  * @property {string} accessibilityMode - Defines the accessibility mode of the route. Possible values are: CHOOSE_SHORTEST, ONLY_NOT_ACCESSIBLE_FLOOR_CHANGES, ONLY_ACCESSIBLE
665
662
  * @property {number} startingAngle - Current user's orientation in degrees.
663
+ * @property {stting[]} includedTags - List of tags that you want to use when calculating a route. Only the tags added here will be used. If there are other tags in the graph they won't be used. The edges without a tag will be used. If you don't set nothing all the graph will be used to calculate the route. You can learn more about this topic on https://situm.com/docs/cartography-management/#tags
664
+ * @property {stting[]} excludedTags - List of tags that you want your route to avoid. If you exclude a tag the route will never pass through an edge that have this tag. If the route can only be generated passing through an edge with this tag the route calculation will fail. You can learn more about this topic on https://situm.com/docs/cartography-management/#tags.
666
665
  */
667
666
 
668
667
  var DirectionsOptions = {
669
668
  minimizeFloorChanges,
670
669
  accessibleRoute,
671
- startingAngle
672
- }
670
+ startingAngle,
671
+ includedTags,
672
+ excludedTags
673
+ };
673
674
 
674
- module.exports = DirectionsOptions
675
+ module.exports = DirectionsOptions;
675
676
 
676
677
  /**
677
678
  * @name
@@ -687,9 +688,9 @@ var OutdoorLocationOptions = {
687
688
  userDefinedThreshold,
688
689
  computeInterval,
689
690
  averageSnrThreshold
690
- }
691
+ };
691
692
 
692
- module.exports = OutdoorLocationOptions
693
+ module.exports = OutdoorLocationOptions;
693
694
 
694
695
  /**
695
696
  * @name
@@ -701,9 +702,9 @@ module.exports = OutdoorLocationOptions
701
702
 
702
703
  var BeaconFilter = {
703
704
  uuid
704
- }
705
+ };
705
706
 
706
- module.exports = BeaconFilter
707
+ module.exports = BeaconFilter;
707
708
 
708
709
  /**
709
710
  * @name
@@ -716,10 +717,10 @@ module.exports = BeaconFilter
716
717
 
717
718
  var RealTimeRequest = {
718
719
  building,
719
- pollTime,
720
- }
720
+ pollTime
721
+ };
721
722
 
722
- module.exports = RealTimeRequest
723
+ module.exports = RealTimeRequest;
723
724
 
724
725
  /**
725
726
  * @name
@@ -730,10 +731,10 @@ module.exports = RealTimeRequest
730
731
  */
731
732
 
732
733
  var RealTimeData = {
733
- locations,
734
- }
734
+ locations
735
+ };
735
736
 
736
- module.exports = RealTimeData
737
+ module.exports = RealTimeData;
737
738
 
738
739
  /**
739
740
  * @name
@@ -747,8 +748,8 @@ module.exports = RealTimeData
747
748
  var PoiSelectedResult = {
748
749
  poi: {
749
750
  identifier,
750
- buildingIdentifier,
751
- },
751
+ buildingIdentifier
752
+ }
752
753
  };
753
754
 
754
755
  module.exports = PoiSelectedResult;
@@ -765,8 +766,8 @@ module.exports = PoiSelectedResult;
765
766
  var PoiDeselectedResult = {
766
767
  poi: {
767
768
  identifier,
768
- buildingIdentifier,
769
+ buildingIdentifier
769
770
  }
770
771
  };
771
772
 
772
- module.exports = PoiDeselectedResult;
773
+ module.exports = PoiDeselectedResult;
@@ -1,4 +1,4 @@
1
- const Situm = require('@situm/cordova.situm')
1
+ const Situm = require('@situm/cordova.situm');
2
2
 
3
3
  /**
4
4
  * Here's an example on how to use this controller class:
@@ -46,35 +46,35 @@ const Situm = require('@situm/cordova.situm')
46
46
  * @name MapViewController
47
47
  */
48
48
  class MapViewControllerImpl {
49
- _onLoadCallback = undefined
50
- _onPoiSelectedCallback = undefined
51
- _onPoiDeselectedCallback = undefined
52
- _buildings = undefined
53
- _mapView = undefined
54
- _isNavigating = false
49
+ _onLoadCallback = undefined;
50
+ _onPoiSelectedCallback = undefined;
51
+ _onPoiDeselectedCallback = undefined;
52
+ _buildings = undefined;
53
+ _mapView = undefined;
54
+ _isNavigating = false;
55
55
 
56
56
  constructor() {
57
- Situm.internalSetEventDelegate(this._handleSdkNativeEvents.bind(this))
57
+ Situm.internalSetEventDelegate(this._handleSdkNativeEvents.bind(this));
58
58
  }
59
59
 
60
60
  _prepare(mapView) {
61
- this._mapView = mapView
61
+ this._mapView = mapView;
62
62
  }
63
63
 
64
64
  _setOnLoadCallback(callback) {
65
- this._onLoadCallback = callback
65
+ this._onLoadCallback = callback;
66
66
  }
67
67
 
68
68
  _sendMessageToViewer(type, payload) {
69
69
  let message = {
70
70
  type: type,
71
- payload: payload,
72
- }
71
+ payload: payload
72
+ };
73
73
  if (this._mapView && this._mapView.firstElementChild) {
74
74
  this._mapView.firstElementChild.contentWindow.postMessage(
75
75
  message,
76
76
  this._mapView._getViewerDomain()
77
- )
77
+ );
78
78
  }
79
79
  }
80
80
 
@@ -88,16 +88,16 @@ class MapViewControllerImpl {
88
88
  // TODO: iOS is sending messages here not related to Location. Check
89
89
  // some fields to avoid assuming that we receive an object of type Location.
90
90
  if (payload.buildingIdentifier && payload.position) {
91
- this._handleOnLocationUpdate(payload)
91
+ this._handleOnLocationUpdate(payload);
92
92
  } else if (payload.statusName) {
93
- this._handleOnLocationStatus(payload)
93
+ this._handleOnLocationStatus(payload);
94
94
  }
95
- break
95
+ break;
96
96
  }
97
97
  }
98
98
 
99
99
  _handleOnLocationUpdate(payload) {
100
- this._sendMessageToViewer('location.update', payload)
100
+ this._sendMessageToViewer('location.update', payload);
101
101
  if (this._isNavigating) {
102
102
  Situm.updateNavigationWithLocation(
103
103
  [payload],
@@ -105,16 +105,16 @@ class MapViewControllerImpl {
105
105
  // Do nothing.
106
106
  },
107
107
  () => {
108
- console.error('Error at updateNavigationWithLocation')
108
+ console.error('Error at updateNavigationWithLocation');
109
109
  }
110
- )
110
+ );
111
111
  }
112
112
  }
113
113
 
114
114
  _handleOnLocationStatus(payload) {
115
115
  this._sendMessageToViewer('location.update_status', {
116
- status: payload.statusName,
117
- })
116
+ status: payload.statusName
117
+ });
118
118
  }
119
119
 
120
120
  // ==================================================
@@ -128,41 +128,41 @@ class MapViewControllerImpl {
128
128
  this._onLoadCallback &&
129
129
  typeof this._onLoadCallback === 'function'
130
130
  ) {
131
- this._onLoadCallback(this)
132
- console.debug('Map is ready!')
131
+ this._onLoadCallback(this);
132
+ console.debug('Map is ready!');
133
133
  }
134
- break
134
+ break;
135
135
  case 'cartography.poi_selected':
136
- console.debug(`poi (${m.payload.identifier}) was selected`)
136
+ console.debug(`poi (${m.payload.identifier}) was selected`);
137
137
  const poiSelectedResult = {
138
138
  poi: {
139
139
  identifier: m.payload.identifier,
140
- buildingIdentifier: m.payload.buildingIdentifier,
141
- },
142
- }
143
- this._onPoiSelectedCallback(poiSelectedResult)
144
- break
140
+ buildingIdentifier: m.payload.buildingIdentifier
141
+ }
142
+ };
143
+ this._onPoiSelectedCallback(poiSelectedResult);
144
+ break;
145
145
  case 'cartography.poi_deselected':
146
146
  const poiDeselectedResult = {
147
147
  poi: {
148
148
  identifier: m.payload.identifier,
149
- buildingIdentifier: m.payload.buildingIdentifier,
150
- },
151
- }
152
- this._onPoiDeselectedCallback(poiDeselectedResult)
153
- break
149
+ buildingIdentifier: m.payload.buildingIdentifier
150
+ }
151
+ };
152
+ this._onPoiDeselectedCallback(poiDeselectedResult);
153
+ break;
154
154
  case 'directions.requested':
155
- this._onDirectionsRequested(m.payload)
156
- break
155
+ this._onDirectionsRequested(m.payload);
156
+ break;
157
157
  case 'navigation.requested':
158
- this._onNavigationRequested(m.payload)
159
- break
158
+ this._onNavigationRequested(m.payload);
159
+ break;
160
160
  case 'navigation.stopped':
161
- this._onNavigationCancel()
162
- break
161
+ this._onNavigationCancel();
162
+ break;
163
163
  default:
164
- console.debug('Got unmanaged message: ', m)
165
- break
164
+ console.debug('Got unmanaged message: ', m);
165
+ break;
166
166
  }
167
167
  }
168
168
 
@@ -171,35 +171,35 @@ class MapViewControllerImpl {
171
171
  if (this._buildings) {
172
172
  let building = this._buildings.find(
173
173
  (b) => b.buildingIdentifier == buildingId
174
- )
175
- callback(building)
174
+ );
175
+ callback(building);
176
176
  } else {
177
177
  // Fetch buildings and calculate route.
178
178
  cordova.plugins.Situm.fetchBuildings(
179
179
  (res) => {
180
- this._buildings = res
180
+ this._buildings = res;
181
181
  let building = this._buildings.find(
182
182
  (b) => b.buildingIdentifier == buildingId
183
- )
184
- callback(building)
183
+ );
184
+ callback(building);
185
185
  },
186
186
  (err) => {
187
- callback(undefined)
187
+ callback(undefined);
188
188
  }
189
- )
189
+ );
190
190
  }
191
191
  }
192
192
 
193
193
  // DIRECTIONS:
194
194
 
195
195
  _onDirectionsRequested(payload) {
196
- let directionsRequest = payload.directionsRequest
196
+ let directionsRequest = payload.directionsRequest;
197
197
  let mapViewerData = {
198
198
  identifier: payload.identifier,
199
199
  originIdentifier: payload.originIdentifier,
200
200
  destinationIdentifier: payload.destinationIdentifier,
201
- type: directionsRequest.accessibilityMode,
202
- }
201
+ type: directionsRequest.accessibilityMode
202
+ };
203
203
  this._ensureBuilding(payload.buildingIdentifier, (building) => {
204
204
  if (building) {
205
205
  Situm.requestDirections(
@@ -207,41 +207,41 @@ class MapViewControllerImpl {
207
207
  building,
208
208
  directionsRequest.from,
209
209
  directionsRequest.to,
210
- directionsRequest,
210
+ directionsRequest
211
211
  ],
212
212
  (route) => {
213
213
  this._sendMessageToViewer('directions.update', {
214
214
  ...route,
215
- ...mapViewerData,
216
- })
215
+ ...mapViewerData
216
+ });
217
217
  },
218
218
  (error) => {
219
219
  this._sendMessageToViewer('directions.update', {
220
220
  error: -1,
221
- identifier: mapViewerData.identifier,
222
- })
221
+ identifier: mapViewerData.identifier
222
+ });
223
223
  }
224
- )
224
+ );
225
225
  } else {
226
226
  this._sendMessageToViewer('directions.update', {
227
227
  error: -1,
228
- identifier: payload.identifier,
229
- })
228
+ identifier: payload.identifier
229
+ });
230
230
  }
231
- })
231
+ });
232
232
  }
233
233
 
234
234
  // NAVIGATION
235
235
 
236
236
  _onNavigationRequested(payload) {
237
- let directionsRequest = payload.directionsRequest
237
+ let directionsRequest = payload.directionsRequest;
238
238
  let mapViewerData = {
239
239
  identifier: payload.identifier,
240
240
  originIdentifier: payload.originIdentifier,
241
241
  destinationIdentifier: payload.destinationIdentifier,
242
- type: directionsRequest.accessibilityMode,
243
- }
244
- let navigationRequest = payload.navigationRequest
242
+ type: directionsRequest.accessibilityMode
243
+ };
244
+ let navigationRequest = payload.navigationRequest;
245
245
  this._ensureBuilding(payload.buildingIdentifier, (building) => {
246
246
  // Request directions again to update the calculated route on the native side.
247
247
  Situm.requestDirections(
@@ -249,62 +249,62 @@ class MapViewControllerImpl {
249
249
  building,
250
250
  directionsRequest.from,
251
251
  directionsRequest.to,
252
- directionsRequest,
252
+ directionsRequest
253
253
  ],
254
254
  (route) => {
255
- this._isNavigating = true
255
+ this._isNavigating = true;
256
256
  this._sendMessageToViewer('navigation.start', {
257
257
  ...route,
258
- ...mapViewerData,
259
- })
258
+ ...mapViewerData
259
+ });
260
260
  Situm.requestNavigationUpdates(
261
261
  [navigationRequest],
262
262
  (progress) => {
263
263
  // Navigation is working, handle different progress types:
264
264
  if (progress.type == 'progress') {
265
- progress.type = 'PROGRESS' // The map-viewer waits for an upper case "type".
266
- this._sendMessageToViewer('navigation.update', progress)
265
+ progress.type = 'PROGRESS'; // The map-viewer waits for an upper case "type".
266
+ this._sendMessageToViewer('navigation.update', progress);
267
267
  } else if (progress.type == 'destinationReached') {
268
268
  this._sendMessageToViewer('navigation.update', {
269
- type: 'DESTINATION_REACHED',
270
- })
271
- this._isNavigating = false
269
+ type: 'DESTINATION_REACHED'
270
+ });
271
+ this._isNavigating = false;
272
272
  } else if (progress.type == 'userOutsideRoute') {
273
273
  this._sendMessageToViewer('navigation.update', {
274
- type: 'OUT_OF_ROUTE',
275
- })
274
+ type: 'OUT_OF_ROUTE'
275
+ });
276
276
  }
277
277
  },
278
278
  (error) => {
279
279
  this._sendMessageToViewer('directions.update', {
280
280
  error: -1,
281
- identifier: mapViewerData.identifier,
282
- })
283
- this._isNavigating = false
281
+ identifier: mapViewerData.identifier
282
+ });
283
+ this._isNavigating = false;
284
284
  }
285
- )
285
+ );
286
286
  },
287
287
  (error) => {
288
288
  this._sendMessageToViewer('directions.update', {
289
289
  error: -1,
290
- identifier: mapViewerData.identifier,
291
- })
292
- this._isNavigating = false
290
+ identifier: mapViewerData.identifier
291
+ });
292
+ this._isNavigating = false;
293
293
  }
294
- )
295
- })
294
+ );
295
+ });
296
296
  }
297
297
 
298
298
  _onNavigationCancel() {
299
- this._isNavigating = false
299
+ this._isNavigating = false;
300
300
  Situm.removeNavigationUpdates(
301
301
  () => {
302
302
  // Do nothing.
303
303
  },
304
304
  () => {
305
- console.error('Error removing navigation updates.')
305
+ console.error('Error removing navigation updates.');
306
306
  }
307
- )
307
+ );
308
308
  }
309
309
 
310
310
  // ==================================================
@@ -321,8 +321,8 @@ class MapViewControllerImpl {
321
321
  * */
322
322
  selectPoi(identifier) {
323
323
  this._sendMessageToViewer('cartography.select_poi', {
324
- identifier: identifier,
325
- })
324
+ identifier: identifier
325
+ });
326
326
  }
327
327
 
328
328
  /**
@@ -344,8 +344,8 @@ class MapViewControllerImpl {
344
344
  navigateToPoi(identifier, accessibilityMode) {
345
345
  this._sendMessageToViewer('navigation.start', {
346
346
  navigationTo: Number.parseInt(identifier),
347
- type: accessibilityMode,
348
- })
347
+ type: accessibilityMode
348
+ });
349
349
  }
350
350
 
351
351
  /**
@@ -358,7 +358,31 @@ class MapViewControllerImpl {
358
358
  * @method
359
359
  */
360
360
  setLanguage(language) {
361
- this._sendMessageToViewer('ui.set_language', language)
361
+ this._sendMessageToViewer('ui.set_language', language);
362
+ }
363
+
364
+ /**
365
+ * @typedef {Object} MapViewDirectionsOptions - Options to apply to directions requests
366
+ * @property {string[]} includedTags - List of tags that you want to use when calculating a route. Only the tags added here will be used. If there are other tags in the graph they won't be used. The edges without a tag will be used. If you don't set any tag, all the graph will be used to calculate the route. You can learn more about this topic on https://situm.com/docs/cartography-management/#tags
367
+ * @property {string[]} excludedTags - List of tags that you want your route to avoid. If you exclude a tag the route will never pass through an edge that have this tag. If the route can only be generated passing through an edge with this tag the route calculation will fail. You can learn more about this topic on https://situm.com/docs/cartography-management/#tags.
368
+ */
369
+
370
+ /**
371
+ * If you want to change the route calculated based on tags you can use this interface.
372
+ * Using this interface you can change all the routes that will be calculated including or excluding tags.
373
+ * Use the method this method after the MapView ends loading
374
+ * You can call this as many times you want and the mapviewer will use the last options that you set.
375
+ *
376
+ * @param {MapViewDirectionsOptions} directionsOptions the desired MapViewDirectionsOptions
377
+ * @memberof MapViewController
378
+ * @name setDirectionsOptions
379
+ * @method
380
+ */
381
+ setDirectionsOptions(directionsOptions) {
382
+ this._sendMessageToViewer('directions.set_options', {
383
+ includedTags: directionsOptions.includedTags,
384
+ excludedTags: directionsOptions.excludedTags
385
+ });
362
386
  }
363
387
 
364
388
  // ==================================================
@@ -373,7 +397,7 @@ class MapViewControllerImpl {
373
397
  * @method
374
398
  * */
375
399
  onPoiSelected(cb) {
376
- this._onPoiSelectedCallback = cb
400
+ this._onPoiSelectedCallback = cb;
377
401
  }
378
402
 
379
403
  /**
@@ -384,9 +408,10 @@ class MapViewControllerImpl {
384
408
  * @method
385
409
  * */
386
410
  onPoiDeselected(cb) {
387
- this._onPoiDeselectedCallback = cb
411
+ this._onPoiDeselectedCallback = cb;
388
412
  }
389
413
  }
390
414
 
391
- let MapViewController = new MapViewControllerImpl()
392
- module.exports = MapViewController
415
+ let MapViewController = new MapViewControllerImpl();
416
+
417
+ module.exports = MapViewController;
package/www/situm.js CHANGED
@@ -79,6 +79,17 @@ var Situm = {
79
79
  exec(cb, error, PLUGIN_NAME, 'setCacheMaxAge', [cacheAge]);
80
80
  },
81
81
 
82
+ /**
83
+ * Get the device id.
84
+ * @description Gets the id of the device.
85
+ * @param {function} cb Cordova native callback to recive data.
86
+ * @param {function} error Cordova native callback to recive errors.
87
+ * @return {void}
88
+ */
89
+ getDeviceId: function (cb, error) {
90
+ exec(cb, error, PLUGIN_NAME, 'getDeviceId');
91
+ },
92
+
82
93
  /**
83
94
  * Set callback and starts listen onLocationChanged event.
84
95
  * @param {LocationRequest} request Location Request.