Using Google Maps api V3 with angular and browserify

核能气质少年 提交于 2019-12-24 22:36:24

问题


I am trying to use the Google Maps Javascript Api V3 inside a Angular + browserify app.

I do not use bower.

Previously I was doing that with requirejs, and a plugins on git hub millermedeiros/requirejs-plugins called async.

I was able to load gmaps like this (most of the time, sometimes requirejs was still requireing gmaps too early.

 // load gmap as an amd module
 define(['config'], function(config){
     define('gmaps', ['async!http://maps.google.com/maps/api/js?v=3&sensor=false&libraries=places&key=' + config['google-map-api-key']],
         function(){
             return window.google.maps;
         }
     );
 });

Browserify is kind of new, I don't see much documentation at this moment, do you guys have any recommendation ?


回答1:


To include CommonJS incompatible scripts have a look at Browserify-shim transform:

https://github.com/thlorenz/browserify-shim



来源:https://stackoverflow.com/questions/26700665/using-google-maps-api-v3-with-angular-and-browserify

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!