@types/googlemaps/index.d.ts' is not a module

后端 未结 10 851
梦谈多话
梦谈多话 2020-12-04 14:25

I want to use the Google Maps API with my Angular project, so I used these two commands to install npm packages:

npm install @agm/core --save-dev
npm install         


        
10条回答
  •  醉酒成梦
    2020-12-04 14:41

        import { MapsAPILoader } from '@agm/core';
        declare var google;
        
        
         constructor(private mapsAPILoader: MapsAPILoader) {
             this.mapsAPILoader.load().then(() => {
                  var mapProp = {
                    center: new google.maps.LatLng(9.93040049002793, -84.09062837772197),
                    zoom: 15,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                  };
                  this.map = new google.maps.Map(this.gmapElement.nativeElement, mapProp);
                });
            
              }
        
        //Hope it helps
    

提交回复
热议问题