Merge into one overlapping polygons leaflet javascript

Viewed 162

I use Angular and leaflet library.

I have a leaflet map to which I add polygons.

I have an arrays of polygon two examples below:

[lat,lng]

There is Poligon1

[48.616537246022794, 14.66313977981373],
[48.61506307648053, 14.660161825380094],
[48.61092122072494, 14.66081369060124],
[48.609057114376665, 14.661409550159924],
[48.60732593279853, 14.662222249186538],
[48.60567014875024, 14.66324025659932],
[48.60407140343632, 14.6645586772402],
[48.60234961899786, 14.666112411267246],
[48.60045569713498, 14.667914788549933],
[48.598390262481406, 14.670071400070768],
[48.59614458470532, 14.672964608745115],
[48.59508894574478, 14.675595174826014],
[48.595037166643046, 14.67760125454089],
[48.595975933585116, 14.67889457935882],
[48.597886777532594, 14.679363773896203],
[48.60064537765358, 14.678711649468468],
[48.60297736223973, 14.677782045949634],
[48.605031495696905, 14.676894484364617],
[48.60686805978407, 14.67609438354239],
[48.60853592002412, 14.675303375365424],
[48.61013909933627, 14.674256050089586],
[48.61174977918272, 14.67294935145318],
[48.613383425836815, 14.67129488551865],
[48.61677448637376, 14.666997672048847]

Poligon 2

 [48.6185460155853, 14.66460900959505],
 [48.61760024222982, 14.662870448220595],
 [48.612846580157424, 14.662891099445012],
 [48.61075006298014, 14.66325901815649],
 [48.60894072674845, 14.664073623647262],
 [48.60724286501672, 14.665023641622266],
 [48.60560626974826, 14.666124588704903],
 [48.6040137754966, 14.66747070326404],
 [48.60230559227243, 14.66907916448798],
 [48.60041402800023, 14.67090851491721],
 [48.598360907069285, 14.673092141366116],
 [48.59628010436201, 14.67590107472824],
 [48.59516715171883, 14.6785046240564],
 [48.59510081862093, 14.680456622023662],
 [48.59602503156683, 14.68169586611009],
 [48.59792856183169, 14.682138046976018],
 [48.60057228684387, 14.681570144665582],
 [48.60291158511264, 14.68066760547457],
 [48.6049735761605, 14.67980706583085],
 [48.60682324146146, 14.679061655601238],
 [48.608497402760264, 14.67829834434976],
 [48.610114720856254, 14.67733396168814],
 [48.6117637255491, 14.67616458502157],
 [48.61344813731478, 14.67472886822722],
 [48.61516043135971, 14.67257803549156],
 [48.61866938668372, 14.666942565010398]

visualisation

I have two tables of points that I draw on the map. I would like the overlapping polygons to be summed into one. Is it possible to combine these areas into one with the help of the leaflet library?

Code that draws a polygon.

const result = polygon(
  LatLngExpression[][]
              {
    smoothFactor: 1,
    interactive: false,
    fillRule: 'nonzero'
  }
);
result.setStyle({
  fillColor: scale.color,
  fillOpacity: this.opacity,
  weight: this.strokeWeight,
  color: 'color'
});
Layer.addLayer(result);
0 Answers
Related