|
16 | 16 | <link href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css" rel="stylesheet" /> |
17 | 17 | <script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.js"></script> |
18 | 18 |
|
19 | | - <!-- Add reference to the fullscreen control module. --> |
20 | | - <script src="/lib/azure-maps/azure-maps-fullscreen-control.min.js"></script> |
21 | | - |
22 | 19 | <script> |
23 | 20 | var map, fullscreenControl; |
24 | 21 |
|
|
47 | 44 |
|
48 | 45 | //Wait for map resources to be ready before loading controls. |
49 | 46 | 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 | | - |
55 | 47 | //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(), { |
57 | 50 | position: 'top-right' |
58 | 51 | }); |
59 | 52 | }); |
| 53 | + |
60 | 54 | } |
61 | 55 |
|
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'; |
65 | 62 |
|
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 |
71 | 67 | }); |
72 | | - } |
73 | 68 |
|
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 | + }); |
86 | 72 | } |
87 | 73 |
|
88 | 74 | function getSelectValue(id) { |
|
116 | 102 | overflow-y: auto; |
117 | 103 | } |
118 | 104 |
|
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 | | - } |
150 | 105 | </style> |
151 | 106 | </head> |
152 | 107 | <body onload="getMap()"> |
153 | 108 |
|
154 | 109 | <div class="testContainer"> |
155 | 110 | <fieldset class="sidePanel"> |
156 | 111 | <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. |
159 | 113 | <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> |
165 | 114 |
|
166 | 115 | <div id="Options" class="tabcontent" style="display:block;"> |
167 | 116 | <table> |
168 | 117 | <tr title="The HTML element that should be made fullscreen."> |
169 | 118 | <td>Container:</td> |
170 | 119 | <td> |
171 | | - <select id="container" onchange="update()" title="Container"> |
| 120 | + <select id="container" onchange="addFullscreenControl()" title="Container"> |
172 | 121 | <option>HTML element</option> |
173 | 122 | <option selected="selected">map</option> |
174 | 123 | </select> |
|
181 | 130 | <tr title="The style of the control."> |
182 | 131 | <td>Style:</td> |
183 | 132 | <td> |
184 | | - <select id="style" onchange="update()" title="Style"> |
| 133 | + <select id="style" onchange="addFullscreenControl()" title="Style"> |
185 | 134 | <option>auto</option> |
186 | 135 | <option>dark</option> |
187 | 136 | <option selected="selected">light</option> |
|
190 | 139 | </tr> |
191 | 140 | </table> |
192 | 141 | </div> |
193 | | - |
194 | | - <div id="EventInfo" class="tabcontent"> |
195 | | - <b>Event info</b><br/> |
196 | | - <textarea id="eventInfo" title="Event info"></textarea> |
197 | | - </div> |
198 | 142 | </fieldset> |
199 | 143 |
|
200 | 144 | <div id="myMap"></div> |
|
0 commit comments