Components: [Discussion] Expose underlying Google Map object

Created on 27 Nov 2019  路  3Comments  路  Source: angular/components

Reproduction

Use StackBlitz to reproduce your issue: https://stackblitz.com/fork/components-issue

Steps to reproduce:

  1. Add
  2. Add @ViewChild(GoogleMap, { static: false }) map: GoogleMap to your component
  3. Construct a KmlLayer:
    kmlLayer: google.maps.KmlLayer = new google.maps.KmlLayer({
    url: '/assets/test.kml',
    });
  1. Try to use the setMap() function:
    ngAfterViewInit() {
    this.kmlLayer.setMap(this.map);
    }

Expected Behavior

What behavior were you expecting to see?
A layer above my map based on the .kml file

Actual Behavior

What behavior did you actually see?
error: InvalidValueError: setMap: not an instance of Map

The current setMap function does not accept a GoogleMap instance as arg...

Environment

  • Angular: 8.2.14
  • CDK/Material: 9.0.0-rc.0
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS
P3 google-maps feature needs discussion

Most helpful comment

Right now the underlying Google Map is the _googleMap property on the GoogleMap component. I think it's a good idea to expose this as googleMap though, so I will do that.

All 3 comments

The reason this does not work is that you're passing the GoogleMap _Angular Component_, not the underlying Google Maps API map object. We don't currently expose this underlying object, but maybe we should.

Right now the underlying Google Map is the _googleMap property on the GoogleMap component. I think it's a good idea to expose this as googleMap though, so I will do that.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

constantinlucian picture constantinlucian  路  3Comments

MurhafSousli picture MurhafSousli  路  3Comments

shlomiassaf picture shlomiassaf  路  3Comments

crutchcorn picture crutchcorn  路  3Comments

Miiekeee picture Miiekeee  路  3Comments