Error: Uncaught TypeError: Cannot read property 'offsetWidth' of null in angularjs for google maps

I am using Google Search Example to implement Google maps on my website. I have added all the JavaScript in the header. However instead of adding below code to I have added it in the template which is loaded in Ng-view:

<input id="pac-input" class="controls" type="text" placeholder="Search Box">
<div id="map-canvas"></div>

When I add the above code in the index.html this error does not occur and the map works. But I need it to load in the ng-view only. How can I do this? Also as stated in the question, this is using angularjs structure and language.

Thanks in advance

Upvotes: 0

Views: 2059

Answers (1)

Roxci William
Roxci William

Reputation: 85

If This is an angular app then you should consider using this: Angular Google Maps

Upvotes: 1

Related Questions