Skip to content

bug: Map's styles property cannot be set when a mapId is present #96

@reslear

Description

@reslear

you can't use styles, but I didn't set the mapId anywhere, but set by default

config.mapId = `capacitor_map_${this.currMapId++}`;

Google Maps JavaScript API: A Map's styles property cannot be set when a mapId is present. When a mapId is present, map styles are controlled via the cloud console. Please see documentation at https://developers.google.com/maps/documentation/javascript/styling#cloud_tooling

Image
  const map = await GoogleMap.create({
    id: 'my-cool-map',
    element: mapRef.value,
    apiKey: '',
    config: {
      center: {
        lat: 33.6,
        lng: -117.9,
      },
      zoom: 8,
      heading: 0,
      minZoom: 0,
      maxZoom: 16,
      styles: [
        {
          featureType: 'poi.attraction',
          elementType: 'all',
          stylers: [{ visibility: 'off' }],
        },
        {
          featureType: 'poi.business',
          stylers: [{ visibility: 'off' }],
        },
        {
          featureType: 'transit',
          elementType: 'labels.icon',
          stylers: [{ visibility: 'off' }],
        },
      ],
    },
  })

I assume that we need to move away from using mapId and use our own id to get the maps

Current solution use cloud based

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions