> For the complete documentation index, see [llms.txt](https://cranford-tech.gitbook.io/beautiful-maps-mapbox/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cranford-tech.gitbook.io/beautiful-maps-mapbox/troubleshooting/error-when-adding-drawing-mode-to-map.md).

# Error when adding Drawing Mode to map

If you run the '**Enable Drawing Mode a MapboxMap**' action on page load, you may get this error:

<figure><img src="https://4212634705-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPwUVbLJRMHVonmvO4xZ8%2Fuploads%2FMUzsN0BlfVqz9yfoxlIS%2FScreenshot%202025-10-08%20at%2008.50.47.png?alt=media&amp;token=bf55723f-4d52-4bf6-b1cb-8cece4393653" alt=""><figcaption></figcaption></figure>

This error is occuring because the Mapbox Map isn't visible on page load.  For example:

* The map may have the 'this element is visible on page load' checkbox unchecked
* The map be in a group/popup/floating group that isn't visible on page load

{% hint style="info" %}
It is recommended to use popups rather than floating groups if you are trying to enable 'Drawing Mode' on a map within that popup/floating group
{% endhint %}

The solution is to run the 'Enable Drawing Mode a Mapbox Map' action when you are making the Map (or its parent element) visible.&#x20;

In the below example, the Mapbox Map is in a popup:

<figure><img src="https://4212634705-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPwUVbLJRMHVonmvO4xZ8%2Fuploads%2F2XEWLuDhRm7FYY9Ofl4I%2FScreenshot%202025-10-08%20at%2008.54.27.png?alt=media&amp;token=2c5a53c8-d71c-46a8-b8d9-9bd85b615d79" alt=""><figcaption></figcaption></figure>

If I try to enable 'Drawing Mode' on page load, an error will occur. However, if I add the 'Enable Drawing Mode' action after the action where I show the popup it will correctly show the popup with the map and drawing mode will be enabled:

<figure><img src="https://4212634705-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPwUVbLJRMHVonmvO4xZ8%2Fuploads%2FAGobnmbbVhfyCPvmP0wU%2FScreenshot%202025-10-08%20at%2008.56.06.png?alt=media&amp;token=05f4db27-096b-437b-9713-b106edba6b28" alt=""><figcaption></figcaption></figure>
