Skip to content

Commit 16f0dc1

Browse files
committed
Update geolocation library and sample
Update geolocation library and sample
1 parent 18ea738 commit 16f0dc1

3 files changed

Lines changed: 284 additions & 65 deletions

File tree

Samples/Device Sensors/Geolocation control options/Geolocation control options.html

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
//Add events to the control.
5353
map.events.add('geolocationerror', geolocationControl, displayEventInfo);
5454
map.events.add('geolocationsuccess', geolocationControl, displayEventInfo);
55+
map.events.add('compassheadingchanged', geolocationControl, (e) => {
56+
displayEventInfo(`Compass heading: ${e}`);
57+
});
5558

5659
//Add control and a style control to the map.
5760
map.controls.add([new atlas.control.StyleControl(), geolocationControl], {
@@ -77,7 +80,11 @@
7780
timeout: parseFloat(document.getElementById('timeout').value)
7881
},
7982
calculateMissingValues: document.getElementById('calculateMissingValues').checked,
80-
maxZoom: parseFloat(document.getElementById('maxZoom').value)
83+
maxZoom: parseFloat(document.getElementById('maxZoom').value),
84+
85+
enableCompass: document.getElementById('enableCompass').checked,
86+
compassEventThrottleDelay: parseFloat(document.getElementById('compassEventThrottleDelay').value),
87+
syncMapCompassHeading: document.getElementById('syncMapCompassHeading').checked
8188
});
8289
}
8390

@@ -117,8 +124,8 @@
117124
}
118125

119126
#eventInfo {
120-
width: 300px;
121-
height: 420px;
127+
width: 290px;
128+
height: 370px;
122129
overflow-y: auto;
123130
}
124131

@@ -152,6 +159,8 @@
152159
padding: 6px 12px;
153160
border: 1px solid #ccc;
154161
border-top: none;
162+
overflow-y: auto;
163+
max-height: 400px;
155164
}
156165
</style>
157166
</head>
@@ -187,6 +196,23 @@
187196
<tr title="Shows the users current location on the map and updates it as they move.">
188197
<td>Track user location:</td>
189198
<td><input id="trackUserLocation" type="checkbox" onclick="update()" title="Track user location" /></td>
199+
</tr>
200+
<tr>
201+
<td>Enable Compass</td>
202+
<td><input id="enableCompass" type="checkbox" checked="true" onclick="update()" /></td>
203+
</tr>
204+
<tr>
205+
<td>Sync Map Compass Heading</td>
206+
<td><input id="syncMapCompassHeading" type="checkbox" onclick="update()" /></td>
207+
</tr>
208+
<tr>
209+
<td>Compass Event Throttle Delay</td>
210+
<td>
211+
<form oninput="ceth.value=compassEventThrottleDelay.value">
212+
<input type="range" id="compassEventThrottleDelay" value="100" min="0" max="5000" step="100" onchange="update()" />
213+
<output name="ceth" for="compassEventThrottleDelay">100</output>
214+
</form>
215+
</td>
190216
</tr>
191217
<tr title="Specifies that if the speed or heading values are missing in the geolocation position, it will calculate these values based on the last known position.">
192218
<td>Calculate missing values:</td>

0 commit comments

Comments
 (0)