Error while setting mapTypeId in Angular Google Map (AGM)

418 Views Asked by At

My code gives the following error while setting [mapTypeId]="'hybrid'" for agm-map

ERROR in src/app/map/google-map/google-map.component.html:1:59 - error TS2322: Type '"hybrid"' is not assignable to type '"HYBRID" | "ROADMAP" | "SATELLITE" | "TERRAIN"'.

1 <agm-map [latitude]="lat" [longitude]="lng" [zoom]="zoom" [mapTypeId]="'hybrid'">
                                                            ~~~~~~~~~~~~~~~~~~~~~~

  src/app/map/google-map/google-map.component.ts:5:16
    5   templateUrl: './google-map.component.html',
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component GoogleMapComponent.
1

There are 1 best solutions below

0
On

Reading through the documentation on https://angular-maps.com/api-docs/agm-core/components/agmmap#source

/**
 * The map mapTypeId. Defaults to 'roadmap'.
 */
@Input() mapTypeId: keyof typeof google.maps.MapTypeId = 'ROADMAP';

So I would try with 'HYBRID' in your case, cause thats the key of the enum. Otherwise you can try using google.maps.MapTypeId.HYBRID