Skip to content

[Bug] MapID giving "ByteString should be constructed with non-empty values" #764

@Dean-Overton

Description

@Dean-Overton

Description

I have recently switched from CRA to Vite and upgraded visgl and typescript.

"dependencies": {
    "@vis.gl/react-google-maps": "^1.5.1",
    "@vitejs/plugin-react": "^4.4.1",
    "vite": "^6.3.3"
    "react": "^18.2.0",
    "react-app-polyfill": "^3.0.0",
},
"devDependencies": {
    "@typescript-eslint/eslint-plugin": "^8.31.1",
    "@typescript-eslint/parser": "^8.31.1",
    "typescript": "^5.8.3",
}

Currently when I comment out the mapID it gives "The map is initialized without a valid Map ID, which will prevent use of Advanced Markers.", but when I use the mapId I receive: main.js:273 Uncaught (in promise) Error: ByteString should be constructed with non-empty values at new _.Ub (main.js:273:744) at o8a (webgl.js:61:148) in the console. Seems to be an error passed from the Google Maps API library. Definitely using a valid mapID as verified by my GCP account.

  <APIProvider apiKey={import.meta.env.VITE_GOOGLE_API_KEY} libraries={["marker"]}>
      {/* <MapContent data={data} theme={theme} /> */}
       <Map
      key={`${currentMapId}-${zoomKey}`}
      mapId={currentMapId}
      style={{ width: "100%", height: "100%" }}
      defaultCenter={{ lat: INITIAL_VIEW_STATE.latitude, lng: INITIAL_VIEW_STATE.longitude }}
      defaultZoom={INITIAL_VIEW_STATE.zoom}
      gestureHandling={"greedy"}
      onClick={() => setActiveMarkerId(null)}
    >
      <MapControls
        visibilitySettings={visibilitySettings}
        onVisibilityChange={handleVisibilityChange}
        points={visiblePoints}
        padding={MAP_CONSTANTS.DEFAULT_PADDING}
      />

      {/* Render map points with pre-calculated offset positions and visibility control */}
      {displayPoints.map((point, index) => {
        // Ensure we always have valid coordinates for latitude and longitude
        const displayLatitude = typeof point.adjustedLatitude === "number" ? point.adjustedLatitude : point.latitude;
        const displayLongitude = typeof point.adjustedLongitude === "number" ? point.adjustedLongitude : point.longitude;

        return (
          <MapMarker
            key={`map-marker-${index}`}
            point={{
              ...point,
              latitude: displayLatitude,
              longitude: displayLongitude,
            }}
            id={`point-${index}`}
            activeMarkerId={activeMarkerId}
            setActiveMarkerId={setActiveMarkerId}
            visibilitySettings={visibilitySettings}
          />
        );
      })}
    </Map>
 </APIProvider>

This was showing the map before with CRA but now fails with vite switch.

Steps to Reproduce

Install versions:

"dependencies": {
    "@vis.gl/react-google-maps": "^1.5.1",
    "@vitejs/plugin-react": "^4.4.1",
    "vite": "^6.3.3"
    "react": "^18.2.0",
    "react-app-polyfill": "^3.0.0",
}
"devDependencies": {
    "@typescript-eslint/eslint-plugin": "^8.31.1",
    "@typescript-eslint/parser": "^8.31.1",
    "typescript": "^5.8.3",
}

vite.config.tsx:

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import eslint from "vite-plugin-eslint";

export default defineConfig({
  optimizeDeps: {
    include: [
      "@deck.gl/core",
      "@deck.gl/layers",
      "@deck.gl/react",
      "@deck.gl/extensions",
      "@deck.gl/geo-layers",
      "@deck.gl/google-maps",
      "@deck.gl/mesh-layers",
      "@luma.gl/constants",
    ],
  },
  plugins: [react(), eslint()],
  base: "/",
  define: {
    global: "globalThis", // This line fixes `global` references
  },
  server: {
    port: 3000,
    open: true,
  },
});

yarn start

Environment

  • Google maps version: weekly
  • Browser and Version: Microsoft Edge Version 136.0.3240.64 (Official build) (64-bit)
  • OS: Windows 11

Logs

Uncaught (in promise) Error: ByteString should be constructed with non-empty values
    at new _.Ub (js?callback=__googleMapsApiOnLoadCallback&key=***REDACTED**&libraries=places:1776:744)
    at o8a (webgl.js:61:148)

Network Logs

https://maps.googleapis.com/maps/api/js/StaticMapService.GetMapImage?1m2&1i59911&2i39245&2e1&3u8&4m2&1u654&2u400&5m5&1e0&5sen-US&6sus&10b1&12b1&7s73128fc4d9f16e4a&8e1&key=**REDACTED**&token=120523 returns 200 OK and first initial render for map.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions