Skip to content

[Bug] Compatibility with Terra Draw #827

@AxelCanton

Description

@AxelCanton

Description

As of august 2025, the drawing manager has been deprecated. It is recommended by the google maps documentation to use libraries such as Terra Draw. However it does not seem to be compatible with this library.

Terra Draw requires the map instance, but also needs the map div to have an id. The issue is that when I provide the id on the Map component, it's the parent of the div returned by mapInstance.getDiv() that possesses the id.

Not sure if this should be opened in the Terra Draw project, or if there is any workaround.

Steps to Reproduce

Minimal exemple to reproduce :

import { TerraDraw, TerraDrawPolygonMode } from "terra-draw";
import { TerraDrawGoogleMapsAdapter } from "terra-draw-google-maps-adapter";
import { Map, useMap } from "@vis.gl/react-google-maps";
import { useEffect } from "react";

const Example = () => {
  const map = useMap("map");

  useEffect(() => {
    if (!map) {
      return;
    }

    const terraDraw = new TerraDraw({
      adapter: new TerraDrawGoogleMapsAdapter({ map, lib: google.maps }),
      modes: [new TerraDrawPolygonMode()],
    });
  });

  return <Map id="map" />;
};

Environment

  • Library version: 1.5.2
  • Google maps version: weekly
  • Browser and Version: chrome 138.0.7204.49
  • OS: Ubuntu 22.04.5

Logs

The error is raised by Terra Draw : Uncaught Error: Google Map container div requires and id to be set

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