Guest User

Untitled

a guest
Feb 20th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. @Component({
  2. selector: "panda-map",
  3. template: `
  4. <div class="map" [style.height.px]="height">
  5. </div>
  6. `
  7. })
  8. export class PandaMapComponent implements OnInit {
  9. @Input() height: string = "400";
  10. @Input() scroll: boolean = false;
  11. map: google.maps.Map;
  12.  
  13. constructor(
  14. private readonly element: ElementRef,
  15. private readonly logger: NGXLogger) {
  16. }
  17.  
  18. ngOnInit(): void {
  19. const div = this.element.nativeElement.querySelector("div");
  20. if (this.map)
  21. return;
  22.  
  23. this.map = new google.maps.Map(
  24. div,
  25. {
  26. zoom: 8,
  27. center: { lat: -26.1714402, lng: 28.0050053 },
  28. mapTypeId: google.maps.MapTypeId.ROADMAP,
  29. scrollwheel: this.scroll
  30. });
  31. google.maps.event.trigger(this.map, "resize");
  32. google.maps.event.addListener(this.map, "idle", function () {
  33. google.maps.event.trigger(this.map, "resize");
  34. });
  35. }
  36. }
  37.  
  38. <div class="pull-left shadow-panel map" *ngIf="address">
  39. <div>
  40. <panda-map [height]="400">
  41. </panda-map>
  42. </div>
  43. </div>
Add Comment
Please, Sign In to add comment