# Node-Red Worldmap: Drawing polygon in worldmap

**URL:** <https://discourse.nodered.org/t/node-red-worldmap-drawing-polygon-in-worldmap/66651>\
**Category:** Dashboard\
**Tags:** node-red-dashboard\
**Created:** [19 August 2022 08:41 UTC](https://discourse.nodered.org/t/node-red-worldmap-drawing-polygon-in-worldmap/66651 "2022-08-19T08:41:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pharos](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@Pharos](https://discourse.nodered.org/u/Pharos)\
**Post date:** [19 August 2022 08:41 UTC](https://discourse.nodered.org/t/node-red-worldmap-drawing-polygon-in-worldmap/66651/1 "2022-08-19T08:41:37Z")

</div>

Hi,

Currently I am working on developing geofences for a project. I am using the Dashboard-Worldmap node in order to draw polygons and save them in a .json file. As it turns out though when executing a GeoIntersect query (mongoDB) with a coordinate point laying within the polygon I get an empty result. Further analysis shows me that the polygon created with the Dashboard-Worldmap node is without the start coordinate at the end, which results in a failing geointersect query.

Example of a rectangle drawing using the dashboard-worldmap node:

```auto
{
	"type": "FeatureCollection",
	"features": [
		{
			"type": "Feature",
			"properties": {
				"Port": "test"
			},
			"geometry": {
				"type": "Polygon",
				"coordinates": [
					[
						[
							5.075828271373202,
							52.5520956610614
						],
						[
							5.075828271373202,
							52.73619031754503
						],
						[
							5.562168359767676,
							52.73619031754503
						],
						[
							5.562168359767676,
							52.5520956610614
						]
					]
				]
			}
		}
	]
}

```

Example of a rectangle drawing for example in [geojson.io](https://geojson.io):

```auto
{
	"type": "FeatureCollection",
	"features": [
		{
			"type": "Feature",
			"properties": {
				"Port": "Test"
			},
			"geometry": {
				"type": "Polygon",
				"coordinates": [
					[
						[
							5.211982727050781,
							52.605132598485969
						],
						[
							5.4087066650390629,
							52.605132598485969
						],
						[
							5.4087066650390629,
							52.72652036177586
						],
						[
							5.211982727050781,
							52.72652036177586
						],
						[
							5.211982727050781,
							52.605132598485969
						]
					]
				]
			}
		}
	]
}

```

Where the [geojson.io](http://geojson.io) adds the start point also as an end point, the worldmap-dashboard node does not. Is this normal functionality or is this a possible fix opportunity?

Node-red-dashboard version 3.1.7  
Node-red-contrib-web-worldmap version 2.21.9

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [20 August 2022 10:34 UTC](https://discourse.nodered.org/t/node-red-worldmap-drawing-polygon-in-worldmap/66651/2 "2022-08-20T10:34:55Z")

</div>

So how are you turning the returned shape into the geoJson ? - The worldmap uses [Leaflet Draw](http://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html) - which only returns the 4 points (for a rectangle) - and also an option.fill set to true if it is supposed to be a filled (closed) object. - you could use this to trigger repeating the first coordinate and adding to the end for your conversion.

---

<div class="post-metadata">

**Author:** ![Pharos](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@Pharos](https://discourse.nodered.org/u/Pharos)\
**Post date:** [21 August 2022 19:15 UTC](https://discourse.nodered.org/t/node-red-worldmap-drawing-polygon-in-worldmap/66651/3 "2022-08-21T19:15:24Z")

</div>

Hi dceejay,

Thanks for your swift reply! So I am using the worldmap interface to draw. I return the shape with the "worldmap in" node.

The output looks as follows, though already mentioning fill:true:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/d/5d3a4310b05641b9dc8de14736f3bc0290977ebb.png)

I am going to test your proposal with option.fill in the worldmap node and will report accordingly.

---

<div class="post-metadata">

**Author:** ![Pharos](https://avatars.discourse-cdn.com/v4/letter/p/65b543/32.png) [@Pharos](https://discourse.nodered.org/u/Pharos)\
**Post date:** [21 August 2022 20:26 UTC](https://discourse.nodered.org/t/node-red-worldmap-drawing-polygon-in-worldmap/66651/4 "2022-08-21T20:26:52Z")

</div>

Fixed the issue. As you mentioned, standard functionality is not to have a closed object. Therefor the solution in the end is to get the first coordinate and add it to the end of the array. Now everything works just fine!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [4 September 2022 20:27 UTC](https://discourse.nodered.org/t/node-red-worldmap-drawing-polygon-in-worldmap/66651/5 "2022-09-04T20:27:09Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
