map
map copied to clipboard
Access google object
Is it possible to access the google object from within a component?
I am trying to get it use it in this way
sv = new google.maps.StreetViewService();
and I am getting a
ERROR ReferenceError: google is not defined
I'm told if you add the
@druedaplata google
is defined global and can be accessed anywhere you just need to make sure is fully loaded see https://github.com/ng2-ui/map/blob/master/src/components/ngui-map.component.ts#L91
i have the same inssue: google is not defined at MapaComponent.webpackJsonp. i call the google on ngOnInit...
I have facing same problem before this..
But it's my temp solution.
When I just used new google.maps.Geocoder;
with out call <ngui-map></ngui-map>
in html
I got same error google is not defined
.
Because
@aitboudad can you add an example of api-loader, https://github.com/ng2-ui/map/blob/master/src/services/api-loader.ts for an application who wants to use Google Maps API directly before ng2-ui/map is loaded?
why not, but for next week :)
until then, i believe this is a hint:
import { NgMapApiLoader } from '@ngui/map';
constructor( private mapsApiLoader: NgMapApiLoader) {
this.mapsApiLoader.api$.subscribe(googleMaps => {
// use as google.maps
});
this.mapsApiLoader.load();
}