1
 window.onload = function() {
  svgPanZoom('#demo-tiger', {
    zoomEnabled: true,
    controlIconsEnabled: true
  });
};

the above code doesn't work with Angular ??

user3157468
  • 11
  • 1
  • 3
  • 1
    Most probably `#demo-tiger` element doesn't exist on `window.onload` event. I'd expect that you should call `svgPanZoom` function after the element is mounted into the DOM. Probably one of `ngAfterViewInit` or `ngAfterViewChecked` callbacks. – bumbu Sep 28 '17 at 09:55

1 Answers1

5

I have used svg-pan-zoom 3.5.x version, following code snippet may help you to import the library.

    // Psuedo angular TS code

    import * as SvgPanZoom from 'svg-pan-zoom';

    @Component({
      selector: 'app-svg-container',
      templateUrl: './svg-container.component.html',
      styleUrls: ['./svg-container.component.scss']
    })
    export class SvgContainerComponent implements OnInit, AfterViewInit {

      constructor() { }

      ngOnInit() {  }

      ngAfterViewInit() {
        // initializing the function
        let svgPanZoom: SvgPanZoom.Instance = SvgPanZoom('#wolrd-map-svg', this.options);
     /* see typing definiton for more APIs. */

      }

        ... More Codes...

    }
Nithin CV
  • 1,046
  • 9
  • 23