I would like to consume the gmaps.js external library in an Angular 2 application. I'm usng Webpack for loading my modules.
Could anyone please help me how i could that?
Thank you in advance...
I would like to consume the gmaps.js external library in an Angular 2 application. I'm usng Webpack for loading my modules.
Could anyone please help me how i could that?
Thank you in advance...
Well there is a library already built for that: angular2-google-maps
I'm currently researching around this problem too because it seems not to be actually a complete out-of-the-box solution at this time since it lacks several features and has a couple of relevant issues, as you can see from the project github open issues page.
but it works indeed and could be the way to go if you're looking for easy to use components for a small side feature of your application.
It's not hard to use it with webpack:
-install the ng2 google maps via npm
npm install angular2-google-maps --save
-import the needed elements
/**
* ng2 Google maps
*/
import {
MapsAPILoader,
NoOpMapsAPILoader,
MouseEvent,
GOOGLE_MAPS_DIRECTIVES,
GOOGLE_MAPS_PROVIDERS
} from 'angular2-google-maps/core';
-and use them within your component: the getting started plunker should work with webpack as well if you take a look at app/main.ts ( I'm not going to post it here 'cause the code isn't mine )