I have an angular2 application and integrated the google map using ng2-map module.
First I tried to specify the google map key in the corresponding module in the @NgModule section like below:
Ng2MapModule.forRoot({
apiUrl: 'https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=drawing,visualization,places&key=GOOGLE_MAP_KEY',
})
But in the module file also there is no way to access the environmental variables and even if it is included, there comes a console error like, google is not defined. Then I have included the google map cdn in the index.html file itself.
Currently, I have included the google map URL in the index.html itself along with the google map key. But the problem is, the keys are different in different environments like development, testing & production etc.
<script src="https://maps.googleapis.com/maps/api/js?v=3.33&libraries=drawing,visualization,places&key=GOOGLE_MAP_KEY"></script>
Since the environmental variables are not scoping in the index.html, I have to manually take care of these google map keys while building(ng build) the project.
Is there any way so that I can give the environment variable in the build commands which should take the corresponding google map key or is there any best practice for that?
Thanks