0

I am trying to add .js file ( this ) to angular project. I tried import * as abc from './marker-clusterer.js'; but console.log gave me an empty object. Any ideas?

tprieboj
  • 1,680
  • 6
  • 31
  • 54
  • check this out. https://stackoverflow.com/questions/37081943/angular2-import-external-js-file-into-component – Anjil Dhamala Dec 20 '17 at 18:56
  • I dont actualy get it :/. – tprieboj Dec 20 '17 at 19:03
  • ideally, you'd want a type definition file for the module you are trying to use as I believe you are working with angular2 and typescript. try using the absolute path to file? something like '../../node_modules/googleMaps/src/marker-clusterer.js' for example. – Anjil Dhamala Dec 20 '17 at 19:06
  • yes. I have file marker-clusterer.js (not in node_modules but it does not batter). But i dont understand how where should I add this file (.d.ts) and what this file should have to make this library working... – tprieboj Dec 20 '17 at 19:13
  • Try using the typescript compiler with the --traceResolution flag to get module resolution log. Info here: https://blog.angularindepth.com/configuring-typescript-compiler-a84ed8f87e3 and here: https://www.typescriptlang.org/docs/handbook/module-resolution.html – Ron Dec 20 '17 at 20:03

1 Answers1

0

Install type definitions for google maps from https://www.npmjs.com/package/@types/googlemaps

Verify that you have actual google maps module installed because type definition files are just empty shells. If you have not, here is a link. https://www.npmjs.com/package/googlemaps

And then import marker-clusterer.ts from @types/googlemaps/"the path to index.d.ts"

Anjil Dhamala
  • 1,544
  • 3
  • 18
  • 37
  • I already have google maps. I just need include the file I wrote in question – tprieboj Dec 20 '17 at 19:26
  • what i want is to add this https://github.com/googlemaps/v3-utility-library/blob/master/markerclustererplus/src/markerclusterer.js ... it is not part of google maps ... i need to add it ... :( – tprieboj Dec 20 '17 at 19:57