@@ -78,7 +78,7 @@ var LitGoogleMap = (function (exports) {
7878 super ( ...arguments ) ;
7979 this . apiKey = "" ;
8080 this . version = "3.48" ;
81- this . styles = { } ;
81+ this . styles = [ ] ;
8282 this . zoom = 8 ;
8383 this . fitToMarkers = false ;
8484 this . mapType = "roadmap" ;
@@ -87,6 +87,10 @@ var LitGoogleMap = (function (exports) {
8787 this . language = "" ;
8888 this . mapId = "DEMO_MAP_ID" ;
8989 this . map = null ;
90+ this . markers = [ ] ;
91+ this . shapes = [ ] ;
92+ this . controls = [ ] ;
93+ this . markerObserverSet = false ;
9094 }
9195 attributeChangedCallback ( name , oldValue , newValue ) {
9296 super . attributeChangedCallback ( name , oldValue , newValue ) ;
@@ -103,49 +107,55 @@ var LitGoogleMap = (function (exports) {
103107 }
104108 }
105109 dispatchViewChanged ( ) {
110+ var _a , _b , _c ;
106111 this . dispatchEvent ( new CustomEvent ( "view_changed" , {
107112 detail : {
108- center : this . map . getCenter ( ) . toJSON ( ) ,
109- zoom : this . map . getZoom ( ) ,
113+ center : ( _b = ( _a = this . map ) === null || _a === void 0 ? void 0 : _a . getCenter ( ) ) === null || _b === void 0 ? void 0 : _b . toJSON ( ) ,
114+ zoom : ( _c = this . map ) === null || _c === void 0 ? void 0 : _c . getZoom ( ) ,
110115 } ,
111116 bubbles : true ,
112117 composed : true ,
113118 } ) ) ;
114119 }
115120 initGMap ( ) {
121+ var _a , _b ;
116122 if ( this . map != null ) {
117123 return ;
118124 }
119- const gMapApiElement = this . shadowRoot . getElementById ( "api" ) ;
125+ const gMapApiElement = ( _a = this . shadowRoot ) === null || _a === void 0 ? void 0 : _a . getElementById ( "api" ) ;
120126 if ( gMapApiElement == null || gMapApiElement . libraryLoaded !== true ) {
121127 return ;
122128 }
123- this . map = new google . maps . Map ( this . shadowRoot . getElementById ( "map" ) , this . getMapOptions ( ) ) ;
129+ this . map = new google . maps . Map ( ( _b = this . shadowRoot ) === null || _b === void 0 ? void 0 : _b . getElementById ( "map" ) , this . getMapOptions ( ) ) ;
124130 this . map . addListener ( "bounds_changed" , ( ) => {
131+ var _a , _b ;
125132 this . dispatchEvent ( new CustomEvent ( "bounds_changed" , {
126- detail : this . map . getBounds ( ) . toJSON ( ) ,
133+ detail : ( _b = ( _a = this . map ) === null || _a === void 0 ? void 0 : _a . getBounds ( ) ) === null || _b === void 0 ? void 0 : _b . toJSON ( ) ,
127134 bubbles : true ,
128135 composed : true ,
129136 } ) ) ;
130137 } ) ;
131138 this . map . addListener ( "tilesloaded" , ( ) => {
139+ var _a , _b ;
132140 this . dispatchEvent ( new CustomEvent ( "tilesloaded" , {
133- detail : this . map . getBounds ( ) . toJSON ( ) ,
141+ detail : ( _b = ( _a = this . map ) === null || _a === void 0 ? void 0 : _a . getBounds ( ) ) === null || _b === void 0 ? void 0 : _b . toJSON ( ) ,
134142 bubbles : true ,
135143 composed : true ,
136144 } ) ) ;
137145 } ) ;
138146 this . map . addListener ( "center_changed" , ( ) => {
147+ var _a , _b ;
139148 this . dispatchEvent ( new CustomEvent ( "center_changed" , {
140- detail : this . map . getCenter ( ) . toJSON ( ) ,
149+ detail : ( _b = ( _a = this . map ) === null || _a === void 0 ? void 0 : _a . getCenter ( ) ) === null || _b === void 0 ? void 0 : _b . toJSON ( ) ,
141150 bubbles : true ,
142151 composed : true ,
143152 } ) ) ;
144153 this . dispatchViewChanged ( ) ;
145154 } ) ;
146155 this . map . addListener ( "zoom_changed" , ( ) => {
156+ var _a ;
147157 this . dispatchEvent ( new CustomEvent ( "zoom_changed" , {
148- detail : { zoom : this . map . getZoom ( ) } ,
158+ detail : { zoom : ( _a = this . map ) === null || _a === void 0 ? void 0 : _a . getZoom ( ) } ,
149159 bubbles : true ,
150160 composed : true ,
151161 } ) ) ;
@@ -225,9 +235,9 @@ var LitGoogleMap = (function (exports) {
225235 this . markerObserverSet = true ;
226236 }
227237 updateMarkers ( ) {
228- var _a ;
238+ var _a , _b ;
229239 this . observeMarkers ( ) ;
230- const markersSelector = this . shadowRoot . getElementById ( "markers-selector" ) ;
240+ const markersSelector = ( _a = this . shadowRoot ) === null || _a === void 0 ? void 0 : _a . getElementById ( "markers-selector" ) ;
231241 if ( ! markersSelector )
232242 return ;
233243 const newMarkers = markersSelector . items ;
@@ -239,7 +249,7 @@ var LitGoogleMap = (function (exports) {
239249 return ;
240250 }
241251 const boundsChanged = this . checkBoundsChanged ( this . markers , newMarkers ) ;
242- const removedMarkers = ( ( _a = this . markers ) === null || _a === void 0 ? void 0 : _a . filter ( ( m ) => {
252+ const removedMarkers = ( ( _b = this . markers ) === null || _b === void 0 ? void 0 : _b . filter ( ( m ) => {
243253 return newMarkers . indexOf ( m ) === - 1 ;
244254 } ) ) || [ ] ;
245255 this . detachChildrenFromMap ( removedMarkers ) ;
@@ -250,7 +260,10 @@ var LitGoogleMap = (function (exports) {
250260 }
251261 }
252262 updateShapes ( ) {
253- const shapesSelector = this . shadowRoot . getElementById ( "shapes-selector" ) ;
263+ var _a ;
264+ if ( ! this . map )
265+ return ;
266+ const shapesSelector = ( _a = this . shadowRoot ) === null || _a === void 0 ? void 0 : _a . getElementById ( "shapes-selector" ) ;
254267 if ( ! shapesSelector )
255268 return ;
256269 this . shapes = shapesSelector . items ;
@@ -259,7 +272,10 @@ var LitGoogleMap = (function (exports) {
259272 }
260273 }
261274 updateControls ( ) {
262- const controlsSelector = this . shadowRoot . getElementById ( "controls-selector" ) ;
275+ var _a ;
276+ if ( ! this . map )
277+ return ;
278+ const controlsSelector = ( _a = this . shadowRoot ) === null || _a === void 0 ? void 0 : _a . getElementById ( "controls-selector" ) ;
263279 if ( ! controlsSelector )
264280 return ;
265281 this . controls = controlsSelector . items ;
@@ -290,10 +306,10 @@ var LitGoogleMap = (function (exports) {
290306 }
291307 checkBoundsChanged ( oldMarkers , newMarkers ) {
292308 const addedInBounds = newMarkers . filter ( ( m ) => {
293- return ! oldMarkers || ! oldMarkers . includes ( m ) ;
309+ return ! ( oldMarkers === null || oldMarkers === void 0 ? void 0 : oldMarkers . includes ( m ) ) ;
294310 } ) ;
295311 const removedInBounds = oldMarkers === null || oldMarkers === void 0 ? void 0 : oldMarkers . filter ( ( m ) => {
296- return ! newMarkers || ! newMarkers . includes ( m ) ;
312+ return ! ( newMarkers === null || newMarkers === void 0 ? void 0 : newMarkers . includes ( m ) ) ;
297313 } ) ;
298314 return addedInBounds . length > 0 || removedInBounds . length > 0 ;
299315 }
@@ -353,7 +369,7 @@ var LitGoogleMap = (function (exports) {
353369 ] , exports . LitGoogleMap . prototype , "version" , void 0 ) ;
354370 __decorate ( [
355371 n ( { type : Object } ) ,
356- __metadata ( "design:type" , Object )
372+ __metadata ( "design:type" , Array )
357373 ] , exports . LitGoogleMap . prototype , "styles" , void 0 ) ;
358374 __decorate ( [
359375 n ( { type : Number } ) ,
@@ -513,10 +529,11 @@ var LitGoogleMap = (function (exports) {
513529 }
514530 }
515531 mapReady ( ) {
532+ var _a ;
516533 this . controlDiv = this . createControlButton ( ) ;
517534 const controlPosition = google . maps . ControlPosition [ this . position ] ;
518535 if ( controlPosition !== undefined ) {
519- this . map . controls [ controlPosition ] . push ( this . controlDiv ) ;
536+ ( _a = this . map ) === null || _a === void 0 ? void 0 : _a . controls [ controlPosition ] . push ( this . controlDiv ) ;
520537 }
521538 }
522539 createControlButton ( ) {
@@ -565,6 +582,7 @@ var LitGoogleMap = (function (exports) {
565582 return controlDiv ;
566583 }
567584 async handleLocationRequest ( ) {
585+ var _a , _b ;
568586 if ( ! navigator . geolocation ) {
569587 this . dispatchEvent ( new CustomEvent ( "location-error" , {
570588 detail : {
@@ -586,8 +604,8 @@ var LitGoogleMap = (function (exports) {
586604 const position = await this . getCurrentPosition ( ) ;
587605 const lat = position . coords . latitude ;
588606 const lng = position . coords . longitude ;
589- this . map . setCenter ( { lat, lng } ) ;
590- this . map . setZoom ( 14 ) ;
607+ ( _a = this . map ) === null || _a === void 0 ? void 0 : _a . setCenter ( { lat, lng } ) ;
608+ ( _b = this . map ) === null || _b === void 0 ? void 0 : _b . setZoom ( 14 ) ;
591609 this . dispatchEvent ( new CustomEvent ( "location-found" , {
592610 detail : { lat, lng } ,
593611 bubbles : true ,
@@ -699,7 +717,7 @@ var LitGoogleMap = (function (exports) {
699717 this . longitude = 0 ;
700718 this . zIndex = 0 ;
701719 this . open = false ;
702- this . id = null ;
720+ this . id = "" ;
703721 this . glyph = null ;
704722 this . glyphColor = null ;
705723 this . background = null ;
@@ -785,8 +803,9 @@ var LitGoogleMap = (function (exports) {
785803 }
786804 mapChanged ( ) {
787805 if ( this . marker ) {
788- this . marker . map = null ;
789- google . maps . event . clearInstanceListeners ( this . marker ) ;
806+ const marker = this . marker ;
807+ marker . map = null ;
808+ google . maps . event . clearInstanceListeners ( marker ) ;
790809 }
791810 if ( this . map && this . map instanceof google . maps . Map ) {
792811 this . mapReady ( ) ;
@@ -845,20 +864,23 @@ var LitGoogleMap = (function (exports) {
845864 if ( content ) {
846865 if ( ! this . info ) {
847866 this . info = new google . maps . InfoWindow ( ) ;
848- this . openInfoHandler = google . maps . event . addListener ( this . marker , "click" , function ( ) {
867+ const marker = this . marker ;
868+ if ( ! marker )
869+ return ;
870+ this . openInfoHandler = google . maps . event . addListener ( marker , "click" , ( ) => {
849871 this . open = true ;
850- } . bind ( this ) ) ;
851- this . closeInfoHandler = google . maps . event . addListener ( this . info , "closeclick" , function ( ) {
872+ } ) ;
873+ this . closeInfoHandler = google . maps . event . addListener ( this . info , "closeclick" , ( ) => {
852874 this . open = false ;
853- } . bind ( this ) ) ;
875+ } ) ;
854876 }
855877 this . info . setContent ( content ) ;
856878 }
857879 else {
858880 if ( this . info ) {
859881 google . maps . event . removeListener ( this . openInfoHandler ) ;
860882 google . maps . event . removeListener ( this . closeInfoHandler ) ;
861- this . info = null ;
883+ this . info = undefined ;
862884 }
863885 }
864886 }
@@ -881,27 +903,27 @@ var LitGoogleMap = (function (exports) {
881903 ] , exports . LitGoogleMapMarker . prototype , "open" , void 0 ) ;
882904 __decorate ( [
883905 n ( { type : String , reflect : true } ) ,
884- __metadata ( "design:type" , String )
906+ __metadata ( "design:type" , Object )
885907 ] , exports . LitGoogleMapMarker . prototype , "id" , void 0 ) ;
886908 __decorate ( [
887909 n ( { type : String , reflect : true } ) ,
888- __metadata ( "design:type" , String )
910+ __metadata ( "design:type" , Object )
889911 ] , exports . LitGoogleMapMarker . prototype , "glyph" , void 0 ) ;
890912 __decorate ( [
891913 n ( { type : String , reflect : true } ) ,
892- __metadata ( "design:type" , String )
914+ __metadata ( "design:type" , Object )
893915 ] , exports . LitGoogleMapMarker . prototype , "glyphColor" , void 0 ) ;
894916 __decorate ( [
895917 n ( { type : String , reflect : true } ) ,
896- __metadata ( "design:type" , String )
918+ __metadata ( "design:type" , Object )
897919 ] , exports . LitGoogleMapMarker . prototype , "background" , void 0 ) ;
898920 __decorate ( [
899921 n ( { type : String , reflect : true } ) ,
900- __metadata ( "design:type" , String )
922+ __metadata ( "design:type" , Object )
901923 ] , exports . LitGoogleMapMarker . prototype , "borderColor" , void 0 ) ;
902924 __decorate ( [
903925 n ( { type : Number , reflect : true } ) ,
904- __metadata ( "design:type" , Number )
926+ __metadata ( "design:type" , Object )
905927 ] , exports . LitGoogleMapMarker . prototype , "scale" , void 0 ) ;
906928 exports . LitGoogleMapMarker = __decorate ( [
907929 t ( "lit-google-map-marker" )
@@ -1015,15 +1037,17 @@ var LitGoogleMap = (function (exports) {
10151037 this . addScript ( scriptUrl ) ;
10161038 }
10171039 addScript ( src ) {
1040+ var _a ;
10181041 const script = document . createElement ( "script" ) ;
10191042 script . src = src ;
10201043 script . onerror = this . handleError . bind ( this ) ;
10211044 const s = document . querySelector ( "script" ) || document . body ;
1022- s . parentNode . insertBefore ( script , s ) ;
1045+ ( _a = s . parentNode ) === null || _a === void 0 ? void 0 : _a . insertBefore ( script , s ) ;
10231046 this . script = script ;
10241047 }
10251048 removeScript ( ) {
1026- if ( this . script . parentNode ) {
1049+ var _a ;
1050+ if ( ( _a = this . script ) === null || _a === void 0 ? void 0 : _a . parentNode ) {
10271051 this . script . parentNode . removeChild ( this . script ) ;
10281052 }
10291053 this . script = null ;
@@ -1043,9 +1067,9 @@ var LitGoogleMap = (function (exports) {
10431067 delete window [ this . callbackName ] ;
10441068 }
10451069 notifyAll ( ) {
1046- this . notifiers . forEach ( function ( notifyCallback ) {
1070+ this . notifiers . forEach ( ( notifyCallback ) => {
10471071 notifyCallback ( this . error , this . result ) ;
1048- } . bind ( this ) ) ;
1072+ } ) ;
10491073 this . notifiers = [ ] ;
10501074 }
10511075 requestNotify ( notifyCallback ) {
@@ -1322,7 +1346,7 @@ var LitGoogleMap = (function (exports) {
13221346 ] , exports . LitSelector . prototype , "activateEvent" , void 0 ) ;
13231347 __decorate ( [
13241348 n ( { type : String , attribute : "selected-attribute" } ) ,
1325- __metadata ( "design:type" , String )
1349+ __metadata ( "design:type" , Object )
13261350 ] , exports . LitSelector . prototype , "selectedAttribute" , void 0 ) ;
13271351 __decorate ( [
13281352 n ( { type : Number , reflect : true } ) ,
0 commit comments