Skip to content

Commit 1bb3fc3

Browse files
author
Savina Shen (Manpower Services Taiwan Co Ltd)
committed
add fullscreen control sample
1 parent e3a684e commit 1bb3fc3

2 files changed

Lines changed: 19 additions & 79 deletions

File tree

‎Samples/Controls/Fullscreen control options/Fullscreen control options.html‎

Lines changed: 19 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<link href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css" rel="stylesheet" />
1717
<script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.js"></script>
1818

19-
<!-- Add reference to the fullscreen control module. -->
20-
<script src="/lib/azure-maps/azure-maps-fullscreen-control.min.js"></script>
21-
2219
<script>
2320
var map, fullscreenControl;
2421

@@ -47,42 +44,31 @@
4744

4845
//Wait for map resources to be ready before loading controls.
4946
map.events.add('ready', function () {
50-
fullscreenControl = new atlas.control.FullscreenControl();
51-
52-
//Add events to the control.
53-
map.events.add('fullscreenchanged', fullscreenControl, displayEventInfo);
54-
5547
//Add control and a style control to the map.
56-
map.controls.add([new atlas.control.StyleControl(), fullscreenControl], {
48+
addFullscreenControl();
49+
map.controls.add(new atlas.control.StyleControl(), {
5750
position: 'top-right'
5851
});
5952
});
53+
6054
}
6155

62-
function displayEventInfo(isFullscreen) {
63-
document.getElementById('eventInfo').value = (isFullscreen) ? 'Not in fullscreen mode' : 'Is in fullscreen mode';
64-
}
56+
function addFullscreenControl() {
57+
map.controls.remove(fullscreenControl);
58+
59+
var style = getSelectValue('style');
60+
var hideIfUnsupported = document.getElementById('hideIfUnsupported').checked;
61+
var container = (getSelectValue('container') === 'map') ? null : '.testContainer';
6562

66-
function update() {
67-
fullscreenControl.setOptions({
68-
style: getSelectValue('style'),
69-
hideIfUnsupported: document.getElementById('hideIfUnsupported').checked,
70-
container: (getSelectValue('container') === 'map') ? null : '.testContainer'
63+
fullscreenControl = new atlas.control.FullscreenControl({
64+
style: style,
65+
hideIfUnsupported: hideIfUnsupported,
66+
container: container
7167
});
72-
}
7368

74-
function openTab(elm, tabName) {
75-
var i, tabcontent, tablinks;
76-
tabcontent = document.getElementsByClassName("tabcontent");
77-
for (i = 0; i < tabcontent.length; i++) {
78-
tabcontent[i].style.display = "none";
79-
}
80-
tablinks = document.getElementsByClassName("tablinks");
81-
for (i = 0; i < tablinks.length; i++) {
82-
tablinks[i].className = tablinks[i].className.replace(" active", "");
83-
}
84-
document.getElementById(tabName).style.display = "block";
85-
elm.className += " active";
69+
map.controls.add(fullscreenControl, {
70+
position: 'top-right'
71+
});
8672
}
8773

8874
function getSelectValue(id) {
@@ -116,59 +102,22 @@
116102
overflow-y: auto;
117103
}
118104

119-
.tab {
120-
overflow: hidden;
121-
border: 1px solid #ccc;
122-
background-color: #f1f1f1;
123-
}
124-
125-
.tab button {
126-
background-color: inherit;
127-
float: left;
128-
border: none;
129-
outline: none;
130-
cursor: pointer;
131-
padding: 6px 8px;
132-
transition: 0.3s;
133-
font-size: 14px;
134-
}
135-
136-
.tab button:hover {
137-
background-color: #ddd;
138-
}
139-
140-
.tab button.active {
141-
background-color: #ccc;
142-
}
143-
144-
.tabcontent {
145-
display: none;
146-
padding: 6px 12px;
147-
border: 1px solid #ccc;
148-
border-top: none;
149-
}
150105
</style>
151106
</head>
152107
<body onload="getMap()">
153108

154109
<div class="testContainer">
155110
<fieldset class="sidePanel">
156111
<legend>Fullscreen control options</legend>
157-
This sample shows all the options of the fullscreen control.
158-
This samples uses the open source <a href="https://github.com/Azure-Samples/azure-maps-fullscreen-control" target="_blank">Azure Maps Fullscreen Control module</a>.
112+
This sample shows how to create a fullscreen control and all of its options.
159113
<br /><br />
160-
161-
<div class="tab">
162-
<button class="tablinks active" onclick="openTab(this, 'Options')">Options</button>
163-
<button class="tablinks" onclick="openTab(this, 'EventInfo')">Event info</button>
164-
</div>
165114

166115
<div id="Options" class="tabcontent" style="display:block;">
167116
<table>
168117
<tr title="The HTML element that should be made fullscreen.">
169118
<td>Container:</td>
170119
<td>
171-
<select id="container" onchange="update()" title="Container">
120+
<select id="container" onchange="addFullscreenControl()" title="Container">
172121
<option>HTML element</option>
173122
<option selected="selected">map</option>
174123
</select>
@@ -181,7 +130,7 @@
181130
<tr title="The style of the control.">
182131
<td>Style:</td>
183132
<td>
184-
<select id="style" onchange="update()" title="Style">
133+
<select id="style" onchange="addFullscreenControl()" title="Style">
185134
<option>auto</option>
186135
<option>dark</option>
187136
<option selected="selected">light</option>
@@ -190,11 +139,6 @@
190139
</tr>
191140
</table>
192141
</div>
193-
194-
<div id="EventInfo" class="tabcontent">
195-
<b>Event info</b><br/>
196-
<textarea id="eventInfo" title="Event info"></textarea>
197-
</div>
198142
</fieldset>
199143

200144
<div id="myMap"></div>

‎Samples/Controls/Fullscreen control/Fullscreen control.html‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
<link href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css" rel="stylesheet" />
1717
<script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.js"></script>
1818

19-
<!-- Load in the JavaScript that has our custom control. -->
20-
<script src="/lib/azure-maps/azure-maps-fullscreen-control.min.js"></script>
21-
2219
<script>
2320
var map;
2421

@@ -69,7 +66,6 @@
6966
<fieldset style="width:calc(100% - 30px);min-width:290px;margin-top:10px;">
7067
<legend>Fullscreen control</legend>
7168
This sample shows how to add a fullscreen button to the map to display it in fullscreen mode.
72-
This samples uses the open source <a href="https://github.com/Azure-Samples/azure-maps-fullscreen-control" target="_blank" title="Azure Maps Fullscreen Control module">Azure Maps Fullscreen Control module</a>.
7369
</fieldset>
7470
</body>
7571
</html>

0 commit comments

Comments
 (0)