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+
1922 < script >
20- var map , fullscreenControl = new atlas . control . FullscreenControl ( ) ;
21-
22- function getMap ( ) {
23- //Initialize a map instance.
24- map = new atlas . Map ( "myMap" , {
25- view : 'Auto' ,
26-
27- //Add authentication details for connecting to Azure Maps.
28- authOptions : {
29- //Use Microsoft Entra ID authentication.
30- authType : 'anonymous' ,
31- clientId : 'e6b6ab59-eb5d-4d25-aa57-581135b927f0' , //Your Azure Maps client id for accessing your Azure Maps account.
32- getToken : function ( resolve , reject , map ) {
33- //URL to your authentication service that retrieves an Microsoft Entra ID Token.
34- var tokenServiceUrl = 'https://samples.azuremaps.com/api/GetAzureMapsToken' ;
35-
36- fetch ( tokenServiceUrl ) . then ( r => r . text ( ) ) . then ( token => resolve ( token ) ) ;
37- }
38-
39- //Alternatively, use an Azure Maps key. Get an Azure Maps key at https://azure.com/maps. NOTE: The primary key should be used as the key.
40- //authType: 'subscriptionKey',
41- //subscriptionKey: '[YOUR_AZURE_MAPS_KEY]'
42- }
43- } ) ;
44-
45- //Wait for map resources to be ready before loading controls.
46- map . events . add ( 'ready' , function ( ) {
47- //Add control and a style control to the map.
48- map . controls . add ( new atlas . control . StyleControl ( ) , {
49- position : 'top-right'
50- } ) ;
51- addFullscreenControl ( ) ;
52- } ) ;
53-
54- }
55-
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 : document . getElementById ( 'testContainer' ) ;
62-
63- fullscreenControl = new atlas . control . FullscreenControl ( {
64- style : style ,
65- hideIfUnsupported : hideIfUnsupported ,
66- container : container
67- } ) ;
68-
69- map . controls . add ( fullscreenControl , {
70- position : 'top-right'
71- } ) ;
72- }
73-
74- function getSelectValue ( id ) {
75- var elm = document . getElementById ( id ) ;
76- return elm . options [ elm . selectedIndex ] . value ;
77- }
78- </ script >
79- < style >
80- # testContainer {
81- background-color : white;
82- }
83-
84- . sidePanel {
85- width : 350px ;
86- height : 580px ;
87- float : left;
88- margin-right : 10px ;
89- }
90-
91- # myMap {
92- position : relative;
93- width : calc ( 100% - 360px ) ;
94- min-width : 290px ;
95- height : 600px ;
96- float : left;
97- }
98- </ style >
23+ var map , fullscreenControl ;
24+
25+ function getMap ( ) {
26+ //Initialize a map instance.
27+ map = new atlas . Map ( "myMap" , {
28+ view : 'Auto' ,
29+
30+ //Add authentication details for connecting to Azure Maps.
31+ authOptions : {
32+ //Use Microsoft Entra ID authentication.
33+ authType : 'anonymous' ,
34+ clientId : 'e6b6ab59-eb5d-4d25-aa57-581135b927f0' , //Your Azure Maps client id for accessing your Azure Maps account.
35+ getToken : function ( resolve , reject , map ) {
36+ //URL to your authentication service that retrieves an Microsoft Entra ID Token.
37+ var tokenServiceUrl = 'https://samples.azuremaps.com/api/GetAzureMapsToken' ;
38+
39+ fetch ( tokenServiceUrl ) . then ( r => r . text ( ) ) . then ( token => resolve ( token ) ) ;
40+ }
41+
42+ //Alternatively, use an Azure Maps key. Get an Azure Maps key at https://azure.com/maps. NOTE: The primary key should be used as the key.
43+ //authType: 'subscriptionKey',
44+ //subscriptionKey: '[YOUR_AZURE_MAPS_KEY]'
45+ }
46+ } ) ;
47+
48+ //Wait for map resources to be ready before loading controls.
49+ 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+ //Add control and a style control to the map.
56+ map . controls . add ( [ new atlas . control . StyleControl ( ) , fullscreenControl ] , {
57+ position : 'top-right'
58+ } ) ;
59+ } ) ;
60+ }
61+
62+ function displayEventInfo ( isFullscreen ) {
63+ document . getElementById ( 'eventInfo' ) . value = ( isFullscreen ) ? 'Not in fullscreen mode' : 'Is in fullscreen mode' ;
64+ }
65+
66+ function update ( ) {
67+ fullscreenControl . setOptions ( {
68+ style : getSelectValue ( 'style' ) ,
69+ hideIfUnsupported : document . getElementById ( 'hideIfUnsupported' ) . checked ,
70+ container : ( getSelectValue ( 'container' ) === 'map' ) ? null : '.testContainer'
71+ } ) ;
72+ }
73+
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" ;
86+ }
87+
88+ function getSelectValue ( id ) {
89+ var elm = document . getElementById ( id ) ;
90+ return elm . options [ elm . selectedIndex ] . value ;
91+ }
92+ </ script >
93+ < style >
94+ . testContainer {
95+ background-color : white;
96+ }
97+
98+ . sidePanel {
99+ width : 325px ;
100+ height : 580px ;
101+ float : left;
102+ margin-right : 10px ;
103+ }
104+
105+ # myMap {
106+ position : relative;
107+ width : calc ( 100% - 375px ) ;
108+ min-width : 290px ;
109+ height : 600px ;
110+ float : left;
111+ }
112+
113+ # eventInfo {
114+ width : 300px ;
115+ height : 420px ;
116+ overflow-y : auto;
117+ }
118+
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+ </ style >
99151</ head >
100152< body onload ="getMap() ">
101- < div id ="testContainer ">
102- < div class ="sidePanel ">
103- < fieldset style ="width: 320px; margin-bottom: 10px ">
104- < legend > Fullscreen control options</ legend >
105- This sample shows how to create a fullscreen control and all of its
106- options.
107- </ fieldset >
108-
109- < table >
110- < tr title ="The HTML element that should be made fullscreen. ">
111- < td > Container:</ td >
112- < td >
113- < select
114- id ="container "
115- onchange ="addFullscreenControl() "
116- title ="Container "
117- >
118- < option > HTML element</ option >
119- < option selected ="selected "> map</ option >
120- </ select >
121- </ td >
122- </ tr >
123- < tr
124- title ="Specifies if the control should be hidden if fullscreen is not supported by the browser. "
125- >
126- < td > Hide if unsupported:</ td >
127- < td >
128- < input
129- id ="hideIfUnsupported "
130- title ="Hide if unsupported "
131- type ="checkbox "
132- checked ="checked "
133- onclick ="addFullscreenControl() "
134- />
135- </ td >
136- </ tr >
137- < tr title ="The style of the control. ">
138- < td > Style:</ td >
139- < td >
140- < select
141- id ="style "
142- onchange ="addFullscreenControl() "
143- title ="Style "
144- >
145- < option > auto</ option >
146- < option > dark</ option >
147- < option selected ="selected "> light</ option >
148- </ select >
149- </ td >
150- </ tr >
151- </ table >
152- </ div >
153153
154- < div id ="myMap "> </ div >
155- </ div >
154+ < div class ="testContainer ">
155+ < fieldset class ="sidePanel ">
156+ < 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 > .
159+ < 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+
166+ < div id ="Options " class ="tabcontent " style ="display:block; ">
167+ < table >
168+ < tr title ="The HTML element that should be made fullscreen. ">
169+ < td > Container:</ td >
170+ < td >
171+ < select id ="container " onchange ="update() " title ="Container ">
172+ < option > HTML element</ option >
173+ < option selected ="selected "> map</ option >
174+ </ select >
175+ </ td >
176+ </ tr >
177+ < tr title ="Specifies if the control should be hidden if fullscreen is not supported by the browser. ">
178+ < td > Hide if unsupported:</ td >
179+ < td > < input id ="hideIfUnsupported " title ="Hide if unsupported " type ="checkbox " checked ="checked " onclick ="update() " /> </ td >
180+ </ tr >
181+ < tr title ="The style of the control. ">
182+ < td > Style:</ td >
183+ < td >
184+ < select id ="style " onchange ="update() " title ="Style ">
185+ < option > auto</ option >
186+ < option > dark</ option >
187+ < option selected ="selected "> light</ option >
188+ </ select >
189+ </ td >
190+ </ tr >
191+ </ table >
192+ </ 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+ </ fieldset >
199+
200+ < div id ="myMap "> </ div >
201+ </ div >
156202</ body >
157203</ html >
0 commit comments