@situm/cordova 3.5.1 → 3.5.3
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.
- package/CHANGELOG_UNRELEASED.md +0 -2
- package/package.json +1 -1
- package/plugin.xml +1 -1
- package/www/map-view-controller.js +10 -0
- package/www/map-view.js +50 -41
package/CHANGELOG_UNRELEASED.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@situm/cordova",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.3",
|
|
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
|
@@ -78,6 +78,16 @@ class MapViewControllerImpl {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
_getDeviceId(callback) {
|
|
82
|
+
Situm.getDeviceId(
|
|
83
|
+
(deviceId) => callback(deviceId),
|
|
84
|
+
() => {
|
|
85
|
+
console.error('Error retrieving the device id.');
|
|
86
|
+
callback(null);
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
81
91
|
// ==================================================
|
|
82
92
|
// SDK MESSAGES:
|
|
83
93
|
// ==================================================
|
package/www/map-view.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const MapViewController = require('./map-view-controller')
|
|
1
|
+
const MapViewController = require('./map-view-controller');
|
|
2
2
|
/**
|
|
3
3
|
* <h4>CODE SNIPPET</h4>
|
|
4
4
|
*
|
|
@@ -12,10 +12,10 @@ const MapViewController = require('./map-view-controller')
|
|
|
12
12
|
* remote-identifier="YOUR_REMOTE_IDENTIFIER"
|
|
13
13
|
* />
|
|
14
14
|
* </pre>
|
|
15
|
-
*
|
|
15
|
+
*
|
|
16
16
|
* <button id="copySnippetButton">Copy</button>
|
|
17
17
|
* </div>
|
|
18
|
-
*
|
|
18
|
+
*
|
|
19
19
|
* <script>
|
|
20
20
|
document.getElementById("copySnippetButton").addEventListener("click", function() {
|
|
21
21
|
var textToCopy = document.getElementById("textToCopy");
|
|
@@ -57,75 +57,84 @@ const MapViewController = require('./map-view-controller')
|
|
|
57
57
|
* @namespace MapView
|
|
58
58
|
*/
|
|
59
59
|
class MapView extends HTMLElement {
|
|
60
|
-
_viewerDomain = 'https://map-viewer.situm.com'
|
|
60
|
+
_viewerDomain = 'https://map-viewer.situm.com';
|
|
61
61
|
|
|
62
62
|
constructor() {
|
|
63
|
-
super()
|
|
63
|
+
super();
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
connectedCallback() {
|
|
67
|
-
MapViewController._prepare(this)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
MapViewController._prepare(this);
|
|
68
|
+
MapViewController._getDeviceId((deviceId) => {
|
|
69
|
+
this.innerHTML = `
|
|
70
|
+
<iframe
|
|
71
|
+
id="map-view-iframe"
|
|
72
|
+
src="${this._getViewerURL(deviceId)}"
|
|
73
|
+
width="100%"
|
|
74
|
+
height="100%"
|
|
75
|
+
style="border: none; box-shadow: none;"
|
|
76
|
+
/>
|
|
77
|
+
`;
|
|
78
|
+
});
|
|
79
|
+
window.addEventListener('message', this._messageReceivedCallback);
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
_getViewerDomain() {
|
|
81
|
-
return this._viewerDomain
|
|
83
|
+
return this._viewerDomain;
|
|
82
84
|
}
|
|
83
85
|
|
|
84
|
-
_getViewerURL() {
|
|
86
|
+
_getViewerURL(deviceId) {
|
|
85
87
|
let viewerDomain = this._formatValidDomain(
|
|
86
88
|
this.getAttribute('viewer-domain')
|
|
87
|
-
)
|
|
88
|
-
let situmApiKey = this.getAttribute('situm-api-key')
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
);
|
|
90
|
+
let situmApiKey = this.getAttribute('situm-api-key')
|
|
91
|
+
? this.getAttribute('situm-api-key')
|
|
92
|
+
: '';
|
|
93
|
+
let buildingIdentifier = this.getAttribute('building-identifier')
|
|
94
|
+
? this.getAttribute('building-identifier')
|
|
95
|
+
: '';
|
|
96
|
+
let language = this.getAttribute('language')
|
|
97
|
+
? this.getAttribute('language')
|
|
98
|
+
: '';
|
|
91
99
|
|
|
92
|
-
let situmApiKeyQP = situmApiKey.length > 0 ? `apikey=${situmApiKey}` : ''
|
|
100
|
+
let situmApiKeyQP = situmApiKey.length > 0 ? `apikey=${situmApiKey}` : '';
|
|
93
101
|
let buildingIdentifierQP =
|
|
94
|
-
buildingIdentifier.length > 0 ? `&buildingid=${buildingIdentifier}` : ''
|
|
95
|
-
let languageQP = language.length > 0 ? `&lng=${language}` : ''
|
|
102
|
+
buildingIdentifier.length > 0 ? `&buildingid=${buildingIdentifier}` : '';
|
|
103
|
+
let languageQP = language.length > 0 ? `&lng=${language}` : '';
|
|
104
|
+
let deviceIdQP = deviceId ? `&deviceId=${deviceId}` : '';
|
|
96
105
|
|
|
97
|
-
let query = `${situmApiKeyQP}${buildingIdentifierQP}${languageQP}&mode=embed
|
|
106
|
+
let query = `${situmApiKeyQP}${buildingIdentifierQP}${languageQP}${deviceIdQP}&mode=embed`;
|
|
98
107
|
|
|
99
|
-
let remoteIdentifier = this.getAttribute('remote-identifier')
|
|
108
|
+
let remoteIdentifier = this.getAttribute('remote-identifier');
|
|
100
109
|
if (remoteIdentifier && remoteIdentifier.length > 0) {
|
|
101
|
-
return `${viewerDomain}/id/${remoteIdentifier}?${query}
|
|
110
|
+
return `${viewerDomain}/id/${remoteIdentifier}?${query}`;
|
|
102
111
|
}
|
|
103
|
-
return `${viewerDomain}/?${query}
|
|
112
|
+
return `${viewerDomain}/?${query}`;
|
|
104
113
|
}
|
|
105
114
|
|
|
106
115
|
_formatValidDomain(domain) {
|
|
107
|
-
let result = domain
|
|
116
|
+
let result = domain;
|
|
108
117
|
if (result == null) {
|
|
109
|
-
return 'https://map-viewer.situm.com'
|
|
118
|
+
return 'https://map-viewer.situm.com';
|
|
110
119
|
}
|
|
111
120
|
if (!result.startsWith('https://') && !result.startsWith('http://')) {
|
|
112
|
-
result = `https://${result}
|
|
121
|
+
result = `https://${result}`;
|
|
113
122
|
}
|
|
114
123
|
if (result.endsWith('/')) {
|
|
115
|
-
result = result.substring(0, result.length - 1)
|
|
124
|
+
result = result.substring(0, result.length - 1);
|
|
116
125
|
}
|
|
117
|
-
this._viewerDomain = result
|
|
118
|
-
return result
|
|
126
|
+
this._viewerDomain = result;
|
|
127
|
+
return result;
|
|
119
128
|
}
|
|
120
129
|
|
|
121
130
|
_messageReceivedCallback(m) {
|
|
122
131
|
try {
|
|
123
|
-
const msg = JSON.parse(m.data)
|
|
132
|
+
const msg = JSON.parse(m.data);
|
|
124
133
|
if (msg && msg.type) {
|
|
125
|
-
MapViewController._handleMapViewMessages(msg)
|
|
134
|
+
MapViewController._handleMapViewMessages(msg);
|
|
126
135
|
}
|
|
127
136
|
} catch (error) {
|
|
128
|
-
console.warn('Got unparseable message:', m)
|
|
137
|
+
console.warn('Got unparseable message:', m);
|
|
129
138
|
}
|
|
130
139
|
}
|
|
131
140
|
|
|
@@ -137,10 +146,10 @@ class MapView extends HTMLElement {
|
|
|
137
146
|
static onLoad(cb) {
|
|
138
147
|
// For now, setting the on-load callback from the integrator is done using this (static) bridge.
|
|
139
148
|
// Probably this could be improved.
|
|
140
|
-
MapViewController._setOnLoadCallback(cb)
|
|
149
|
+
MapViewController._setOnLoadCallback(cb);
|
|
141
150
|
}
|
|
142
151
|
}
|
|
143
152
|
|
|
144
|
-
customElements.define('map-view', MapView)
|
|
153
|
+
customElements.define('map-view', MapView);
|
|
145
154
|
|
|
146
|
-
module.exports = MapView
|
|
155
|
+
module.exports = MapView;
|