angular-google-maps icon indicating copy to clipboard operation
angular-google-maps copied to clipboard

QUESTION: Importing maps into submodule of app.module is not working

Open chriseenberg opened this issue 9 years ago • 4 comments

UPDATE: I found the problem. I was using ng2-boostrap tabset module, when adding the maps inside this view, the map does not render. I haven't been able to fix the problem though.

Issue description Importing the maps module into a secondary module gives a blank map with no errors in the console.

Steps to reproduce and a minimal demo of the problem Add the module to a different module than the app.module. Importing the maps module into the newly created module and using the maps selector in html will create a blank map

Current behavior maps is blank - i.e. no streets or water is loaded.

screen shot 2017-02-06 at 14 03 36

Expected/desired behavior map should show content - and markers.

angular2 & angular-google-maps version angular cli - angular2 version: 2.4.x - maps version 0.17.0

Other information link to stackoverflow issue: http://stackoverflow.com/questions/42067392/using-sebm-google-maps-module-in-child-component-shows-blank-map

Please read the stackoverflow post as it describes exactly what i've tried.

Kind regards Chris

chriseenberg avatar Feb 06 '17 13:02 chriseenberg

Did you tried this code in your component that is responsible for viewing the map?

import {MapsAPILoader, SebmGoogleMap} from 'angular2-google-maps/core'; @ViewChild(SebmGoogleMap) map: SebmGoogleMap;

this.map.triggerResize();

efstathiosntonas avatar Feb 07 '17 06:02 efstathiosntonas

i tried that just now, and no result, the map is still the same.. i call the triggerResize() within my ngOnInit lifecycle hook. Maybe there is a better place for it? i will try some different approaches to it. Thanks for your time!

chriseenberg avatar Feb 07 '17 08:02 chriseenberg

it works! i added the function to a button, and now it works! Thank you so much!

chriseenberg avatar Feb 07 '17 08:02 chriseenberg

I added on the ngAfterViewChecked and works fine. @chriseenberg you might want to avoid the user to click a button, if so you can try my approach

jmontaca avatar Feb 10 '17 13:02 jmontaca