Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

leaflet-FreeDraw for angular 4 #123

Open
Zahma opened this issue Jun 22, 2018 · 4 comments
Open

leaflet-FreeDraw for angular 4 #123

Zahma opened this issue Jun 22, 2018 · 4 comments

Comments

@Zahma
Copy link

Zahma commented Jun 22, 2018

Hello I'm using the following module in angular 4:

https://github.com/Wildhoney/Leaflet.FreeDraw

in the following way:

import { FreeDraw } from 'leaflet-freedraw';

The project is compiling, which means that there is no problem of typings.

However, I'm getting the following error in the console:

Uncaught ReferenceError: regeneratorRuntime is not defined

I tried another solution, which is to import the project directly as JS, and write the typings as follow:

import 'leaflet-freedraw/dist/leaflet-freedraw.web.js';
import { FreeDraw } from '../xxx/freeDraw-typings';
with freeDaw-typings containing the following:

export class FreeDraw {
constructor(params?: any);
on(params: any):any;
mode(params: any):any;
create(params: any):any;
}
but I get the following:

ERROR in ./src/main/webapp/app/xxxxx/xxxx/xxx.component.ts

Module not found: Error: Can't resolve '../xxx/freeDraw-typings'

@Wildhoney
Copy link
Owner

For the regeneratorRuntime issue you will need to bundle https://babeljs.io/docs/en/babel-polyfill.html with your build 👍

@Zahma
Copy link
Author

Zahma commented Jun 22, 2018

@Wildhoney thank you for the answer, you mean that I should include babel-polyfill in my packages ?

@Wildhoney
Copy link
Owner

Yep, and then if you're using Webpack you can do something like:

module.exports = {
  entry: ["babel-polyfill", "./app.js"]
};

@Zahma
Copy link
Author

Zahma commented Aug 6, 2018

@Wildhoney thank you for your help, in fact I did it as you said, the library is apparently well imported. Still, I get a weired error:
ERROR TypeError: leaflet_freedraw_1.FreeDraw is not a constructor
Knowing that Accessing FreeDraw throgh window['FreeDraw'] or directly through FreeDraw is displaying the object.

FreeDraw() {
    var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultOptions;

    _classCallCheck(this, FreeDraw);

    var _this = _possibleConstructorReturn(th…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants