@@ -11,25 +11,11 @@ import {
1111import { IgrButton , IgrDialog , IgrInput , IgrSelect , IgrSelectItem } from "igniteui-react" ;
1212import { IgrDataChartInteractivityModule } from "igniteui-react-charts" ;
1313import "igniteui-webcomponents/themes/light/bootstrap.css" ;
14+ import { MapUtils , MapRegion } from './MapUtils' ;
1415
1516IgrGeographicMapModule . register ( ) ;
1617IgrDataChartInteractivityModule . register ( ) ;
1718
18- enum MapRegion { UnitedStates }
19-
20- class MapUtils {
21- public static navigateTo ( geoMap : IgrGeographicMap | undefined , region : MapRegion ) {
22- if ( ! geoMap ) return ;
23- if ( region === MapRegion . UnitedStates )
24- geoMap . zoomToGeographic ( { left : - 125 , top : 50 , width : 60 , height : 25 } ) ;
25- }
26-
27- public static zoomToNYC ( geoMap : IgrGeographicMap | undefined ) {
28- if ( ! geoMap ) return ;
29- geoMap . zoomToGeographic ( { left : - 74.2591 , top : 40.9176 , width : - 73.7004 - ( - 74.2591 ) , height : 40.4774 - 40.9176 } ) ;
30- }
31- }
32-
3319const placeholderImages : Record < string , string > = {
3420 Satellite : "https://static.infragistics.com/xplatform/images/browsers/azure-maps/azure_satellite.png" ,
3521 Road : "https://static.infragistics.com/xplatform/images/browsers/azure-maps/azure_road.png" ,
@@ -73,27 +59,30 @@ export default class MapDisplayImageryAzure extends React.Component<any, any> {
7359 this . onStyleChange = this . onStyleChange . bind ( this ) ;
7460 }
7561
62+ componentDidMount ( ) {
63+ this . onDialogShow ( ) ; // open dialog on startup
64+ }
65+
7666 render ( ) : JSX . Element {
7767 return (
7868 < div
7969 style = { {
8070 display : "flex" ,
8171 flexDirection : "column" ,
82- alignItems : "center" ,
83- gap : "16px" ,
72+ height : "100vh" , // full viewport
8473 width : "100%" ,
85- padding : "16px" ,
86- boxSizing : "border-box"
8774 } }
8875 >
8976 { /* Controls panel */ }
9077 < div
9178 style = { {
79+ flex : "0 0 auto" , // fixed height
9280 display : "flex" ,
9381 gap : "12px" ,
9482 alignItems : "center" ,
9583 justifyContent : "center" ,
96- flexWrap : "wrap"
84+ padding : "12px" ,
85+ zIndex : 2
9786 } }
9887 >
9988 < IgrButton variant = "contained" onClick = { this . onDialogShow } >
@@ -113,51 +102,41 @@ export default class MapDisplayImageryAzure extends React.Component<any, any> {
113102 </ IgrSelect >
114103 </ div >
115104
116- { /* Placeholder image */ }
117- { ! this . state . mapVisible && (
118- < div
119- style = { {
120- width : "640px" ,
121- height : "480px" ,
122- display : "flex" ,
123- justifyContent : "center" ,
124- alignItems : "center" ,
125- border : "1px solid #ccc" ,
126- borderRadius : "6px" ,
127- overflow : "hidden" ,
128- boxShadow : "0 2px 6px rgba(0,0,0,0.2)"
129- } }
130- >
131- < img
132- src = { placeholderImages [ this . state . styleName ] }
133- alt = { this . state . styleName }
134- style = { { width : "100%" , height : "100%" , objectFit : "cover" } }
135- />
136- </ div >
137- ) }
138-
139- { /* Map container */ }
105+ { /* Placeholder image or map fills the rest */ }
140106 < div
141107 style = { {
142- width : "100%" ,
143- maxWidth : "100%" ,
144- height : "1000px" ,
108+ width : "100%" , // fill parent container width
109+ maxWidth : "960px" , // constrain max width
110+ aspectRatio : "4 / 3" , // maintain 4:3 ratio
111+ margin : "0 auto" , // center horizontally
112+ position : "relative" ,
145113 overflow : "hidden" ,
146- display : this . state . mapVisible ? "block" : "none"
147114 } }
148115 >
149- < IgrGeographicMap
150- ref = { ( r ) => ( this . geoMap = r ! ) }
151- width = "100%"
152- height = "100%"
153- zoomable = { true }
154- />
116+ { ! this . state . mapVisible ? (
117+ < img
118+ src = { placeholderImages [ this . state . styleName ] }
119+ alt = { this . state . styleName }
120+ style = { {
121+ width : "100%" ,
122+ height : "100%" ,
123+ objectFit : "cover"
124+ } }
125+ />
126+ ) : (
127+ < IgrGeographicMap
128+ ref = { ( r ) => ( this . geoMap = r ! ) }
129+ width = "100%"
130+ height = "100%"
131+ zoomable = { true }
132+ />
133+ ) }
155134 </ div >
156135
157- { /* Dialog for API key */ }
158- < IgrDialog title = "Azure Key" ref = { this . onDialogRef } >
136+ { /* Dialog always floats above */ }
137+ < IgrDialog title = "Azure Key" ref = { this . onDialogRef } className = "igr-dialog" >
159138 < IgrInput
160- label = "Azure Key "
139+ label = "An image will remain visible when no key is entered. "
161140 value = { this . state . apiKey }
162141 inputMode = "text"
163142 onInput = { this . onApiKeyChange }
@@ -182,6 +161,7 @@ export default class MapDisplayImageryAzure extends React.Component<any, any> {
182161 ) ;
183162}
184163
164+
185165 private onDialogRef ( dialog : IgrDialog ) { this . dialogRef = dialog ; }
186166 private onDialogShow ( ) { this . dialogRef ?. show ( ) ; }
187167 private onDialogHide ( ) { this . dialogRef ?. hide ( ) ; }
@@ -243,7 +223,7 @@ export default class MapDisplayImageryAzure extends React.Component<any, any> {
243223 if ( style === AzureMapsImageryStyle . WeatherInfraredOverlay || style === AzureMapsImageryStyle . WeatherRadarOverlay ) {
244224 MapUtils . navigateTo ( this . geoMap , MapRegion . UnitedStates ) ;
245225 } else {
246- MapUtils . zoomToNYC ( this . geoMap ) ;
226+ this . geoMap . zoomToGeographic ( { left : - 74.2591 , top : 40.9176 , width : - 73.7004 - ( - 74.2591 ) , height : 40.4774 - 40.9176 } ) ;
247227 }
248228 }
249229 else if ( style === AzureMapsImageryStyle . TerraOverlay ) {
0 commit comments