map icon indicating copy to clipboard operation
map copied to clipboard

Access google object

Open druedaplata opened this issue 7 years ago • 7 comments

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

druedaplata avatar Jul 05 '17 17:07 druedaplata

I'm told if you add the

vanderburg avatar Jul 07 '17 01:07 vanderburg

@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

aitboudad avatar Jul 17 '17 10:07 aitboudad

i have the same inssue: google is not defined at MapaComponent.webpackJsonp. i call the google on ngOnInit...

becerriljc avatar Jul 31 '17 23:07 becerriljc

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

mzm-dev avatar Aug 09 '17 00:08 mzm-dev

@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?

allenhwkim avatar Aug 09 '17 02:08 allenhwkim

why not, but for next week :)

aitboudad avatar Aug 11 '17 18:08 aitboudad

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();
}

gregor-srdic avatar Aug 13 '17 14:08 gregor-srdic