UNPKG

sdk-google-map

Version:

Simple to use (Angular) embedded Google map.

1 lines 9.06 kB
{"version":3,"file":"sdk-google-map.mjs","sources":["../../../projects/sdk-google-map/src/lib/sdk-google-map.component.ts","../../../projects/sdk-google-map/src/lib/sdk-google-map.component.html","../../../projects/sdk-google-map/src/lib/sdk-google-map.module.ts","../../../projects/sdk-google-map/src/public-api.ts","../../../projects/sdk-google-map/src/sdk-google-map.ts"],"sourcesContent":["import { Component, ElementRef, Input, ViewChild } from '@angular/core';\n\nimport { SDKLoadingModule } from 'sdk-loading';\n\n@Component({\n\tselector: 'sdk-google-map',\n\tstandalone: true,\n\timports: [SDKLoadingModule],\n\ttemplateUrl: './sdk-google-map.component.html'\n})\n\nexport class SDKGoogleMapComponent {\n\t/**************************************************************************\n\t* Input/Output Parameters\n\t**************************************************************************/\n\t@Input() height: string = \"\";\n\t@Input() width: string = \"\";\n\t@Input() latitude: string = \"\";\n\t@Input() longitude: string = \"\";\n\t@Input() location: string = \"\";\n\t@Input() zoom: string = \"10\";\n\t@Input() border: string = \"1px solid lightgray\";\n\n\t/**************************************************************************\n\t* Component Variables\n\t**************************************************************************/\n\t@ViewChild(\"map\") map: ElementRef | undefined;\n\n\tprotected isLoading: boolean = false;\n\n\tprotected _height: string = \"\";\n\tprotected _width: string = \"\";\n\n\t/**************************************************************************\n\t* Component Lifecycle Methods\n\t**************************************************************************/\n\tprotected ngOnChanges(_args: any) {\n\t\tif (_args.latitude || _args.longitude || _args.location || _args.zoom) {\n\t\t\tif (_args.latitude !== \"\" || _args.longitude !== \"\" || _args.location !== \"\") {\n\t\t\t\tthis.loadMap();\n\t\t\t}\n\t\t}\n\n\t\tif ((_args.height && _args.height !== \"\") || (_args.width && _args.width !== \"\")) {\n\t\t\tthis.setMap();\n\t\t}\n\t}\n\n\t/**************************************************************************\n\t* Private Methods\n\t**************************************************************************/\n\tprivate setMap() {\n\t\tif (this.height !== \"\" && this.width === \"\") {\n\t\t\tthis._height = this.height;\n\t\t\tthis._width = this.height;\n\t\t}\n\t\telse if (this.height === \"\" && this.width !== \"\") {\n\t\t\tthis._height = this.width;\n\t\t\tthis._width = this.width;\n\t\t}\n\t\telse if (this.height !== \"\" && this.width !== \"\") {\n\t\t\tthis._height = this.height;\n\t\t\tthis._width = this.width;\n\t\t} else {\n\t\t\tthis._height = \"300px\";\n\t\t\tthis._width = \"300px\";\n\t\t}\n\t}\n\n\tprivate loadMap() {\n\t\tthis.isLoading = true;\n\n\t\tlet src: string = \"\";\n\n\t\tif (this.latitude && this.latitude !== \"\" && this.longitude && this.longitude !== \"\") {\n\t\t\tsrc = `<iframe id=\"sdk-google-map-iframe\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"https://maps.google.com/maps?width=100%25&amp;height=100%25&amp;hl=en&amp;q=${this.latitude},${this.longitude}&amp;t=&amp;z=${this.zoom}&amp;ie=UTF8&amp;iwloc=B&amp;output=embed\"></iframe>`;\n\t\t} else if (this.location && this.location !== \"\") {\n\t\t\tsrc = `<iframe id=\"sdk-google-map-iframe\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" src=\"https://maps.google.com/maps?width=100%25&amp;height=100%25&amp;hl=en&amp;q=${encodeURI(this.location)}&amp;t=&amp;z=${this.zoom}&amp;ie=UTF8&amp;iwloc=B&amp;output=embed\"></iframe>`;\n\t\t} else {\n\t\t\tsrc = `<div style=\"display: flex; width: 100%; height: 100%; align-items: center;\"><div style=\"width: 100%; text-align: center;\">Insufficient data.</div></div>`;\n\t\t}\n\n\t\tsetTimeout(() => {\n\t\t\tthis.map!.nativeElement.innerHTML = src ?? \"\";\n\n\t\t\tlet iframe = document.getElementById('sdk-google-map-iframe');\n\n\t\t\tif (iframe) {\n\t\t\t\tiframe.onload = () => {\n\t\t\t\t\tthis.isLoading = false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.isLoading = false;\n\t\t\t}\n\t\t}, 100);\n\t}\n}\n","<div [style]=\"'position: relative; height: ' + _height + '; width: ' + _width + '; border: ' + border + ';'\">\n <div #map style=\"height: 100%; width: 100%;\"></div>\n <sdk-loading [isLoading]=\"isLoading\"></sdk-loading>\n</div>\n","import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';\nimport { SDKGoogleMapComponent } from './sdk-google-map.component';\n\n@NgModule({\n imports: [\n SDKGoogleMapComponent\n ],\n exports: [\n SDKGoogleMapComponent\n ],\n schemas: [\n NO_ERRORS_SCHEMA\n ]\n})\nexport class SDKGoogleMapModule { }\n","/*\n * Public API Surface of sdk-google-map\n */\n\nexport { SDKGoogleMapModule } from './lib/sdk-google-map.module';\nexport { SDKGoogleMapComponent } from './lib/sdk-google-map.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;MAWa,qBAAqB,CAAA;AAPlC,IAAA,WAAA,GAAA;AAQC;;AAE2E;QAClE,IAAM,CAAA,MAAA,GAAW,EAAE;QACnB,IAAK,CAAA,KAAA,GAAW,EAAE;QAClB,IAAQ,CAAA,QAAA,GAAW,EAAE;QACrB,IAAS,CAAA,SAAA,GAAW,EAAE;QACtB,IAAQ,CAAA,QAAA,GAAW,EAAE;QACrB,IAAI,CAAA,IAAA,GAAW,IAAI;QACnB,IAAM,CAAA,MAAA,GAAW,qBAAqB;QAOrC,IAAS,CAAA,SAAA,GAAY,KAAK;QAE1B,IAAO,CAAA,OAAA,GAAW,EAAE;QACpB,IAAM,CAAA,MAAA,GAAW,EAAE;AAiE7B;AA/DA;;AAE2E;AACjE,IAAA,WAAW,CAAC,KAAU,EAAA;AAC/B,QAAA,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE;AACtE,YAAA,IAAI,KAAK,CAAC,QAAQ,KAAK,EAAE,IAAI,KAAK,CAAC,SAAS,KAAK,EAAE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