loading google map in angular.dart view (ng-view)

前端 未结 2 646
没有蜡笔的小新
没有蜡笔的小新 2020-12-12 00:35

I am trying to create a single page app in angular.dart with multiple views, but I cant find a working example of loading up a Google M

2条回答
  •  情话喂你
    2020-12-12 01:03

    I managed to get this working by letting the city-ctrl directive implement NgAttachAware interface method attach(), and initiate the Maps from there. The constructor was obviously the wrong place for that. The following worked out:

    @NgDirective(
      selector: '[city-ctrl]'
    )
    class CityController implements NgAttachAware {
    
      CityController() {
      }
    
      attach() {    
        final mapOptions = new MapOptions()
        ..zoom = 8
        ..center = new LatLng(-34.397, 150.644)
        ..mapTypeId = MapTypeId.ROADMAP
        ;
        final map = new GMap(querySelector("#city_map_canvas"), mapOptions);
      }
    
    }
    

提交回复
热议问题