-
-
Notifications
You must be signed in to change notification settings - Fork 93
Description
Describe the bug
When attempting to draw the third point of a polygon using a custom modeName (e.g., "Polygon" instead of the default "polygon"), the terra-draw-google-maps-adapter throws a styling error.
The crash occurs because the internal "point" feature is created with the mode "polygon", ignoring the custom modeName defined in the TerraDrawPolygonMode configuration.
Since the adapter uses the mode property to look up styles, it fails to find the styles registered under the custom name (e.g., "Polygon"), passing invalid parameters and causing the following error:
terra-draw-google-maps-adapter.ts:435 Uncaught TypeError: t2[r2] is not a function
JSON Evidence
As seen in the snapshot below, the main Polygon feature respects the custom mode ("mode": "Polygon"), but the generated closing points revert to the default ("mode": "polygon"), causing the mismatch:
[
{
"id": "0028a6db-4700-49f7-8641-14f185b35a44",
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-52.57199132232667,
-13.26390582065197
],
[
-52.03366124420167,
-13.36547044032876
],
[
-52.18197667388916,
-13.691255825334935
],
[
-52.18197667388916,
-13.691255825334935
],
[
-52.57199132232667,
-13.26390582065197
]
]
]
},
"properties": {
"mode": "Polygon", // <--- Correct: My custom modeName
"currentlyDrawing": true,
"committedCoordinateCount": 2,
"provisionalCoordinateCount": 3
}
},
{
"id": "93561f3b-7cd7-4572-871f-8860d1d7e2a3",
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-52.57199132232667,
-13.26390582065197
]
},
"properties": {
"mode": "polygon",
"closingPoint": true
}
},
{
"id": "ae53e27c-bdb6-46e0-9cff-2f85567b18be",
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-52.18197667388916,
-13.691255825334935
]
},
"properties": {
"mode": "polygon", // <--- INCORRECT: Ignores custom modeName
"closingPoint": true
}
}
]
Terra Draw npm version
{
"terra-draw": "^1.20.0",
"terra-draw-google-maps-adapter": "^1.1.2"
}
To Reproduce
Steps to reproduce the behavior:
- Create a TerraDrawPolygonMode with a custom modeName.
- Switch the drawing mode to this custom mode and start drawing a polygon.
- When adding the third point, observe the error in the browser console.
Expected behavior
All internally generated features related to the polygon (including closing points) should respect the configured modeName. This ensures consistent style resolution and prevents runtime errors in the adapter.