Is it possible in Leaflet, to share a single common boundary within two polygons, other than two overlapped boundaries within a MultiPolygon layer?

In this plugin (leaflet-geoman), they have mentioned there is an option in pro version, called pining. But in that pining option (you can see it on the gif), it has duplicate boundaries on top of each other. What I want to achieve is, multipolygons must share common boundaries like on this question. But on this quetion it was about MultiLineStrings, not about MultiPolygons. The answer was given using TopoJSON. It has a method called topojson.mesh which

Returns the GeoJSON MultiLineString geometry object representing the mesh for the specified object in the given topology. This is useful for rendering strokes in complicated objects efficiently, as edges that are shared by multiple features are only stroked once.

But there is no method for returning MultiPolygons for a given topology. It only has a method for returning MultiPolygons called topojson.merge wich

to merge multiple polygons into a single polygon whilst removing interior borders.

So my ultimate goal is to have MultiPolygon layer which consist with single shared boundary within two polygons, not duplicated boundaries on top of each other or overlapped boundaries. What I need is exactly in this video. But it is done using overlapped boundaries. Not using shared single boundaries.

I tried it using the exact plugin used on above video. It has mentioned on repository that

In its current design, editing large datasets is not possible because of the massive amount of time required to find matching and missing vertices.

Is there anyway I can achieve this using Leaflet or any other method.

  • 2
    You probably want to do some research on TopoJSON. – IvanSanchez Jun 24 at 8:32
  • @IvanSanchez Have you came across any need like above, Any possible hint on where should I look for on TopoJSON would be highly appreciated. Thank you for your directions. – Hashan hemachandra Jun 24 at 8:38
  • 1
    Just have a look at TopoJSON depcification at github.com/topojson/topojson-specification and how polygons/multipolygons are constructed from basic elements called arcs. Each arc as an array of coordinates which you refer to by it's index in the array of all arcs. So common polygon boundary can be specified only once as one arc element and then referenced as many times as needed when onstructing polygons/multipolygons. – TomazicM Jun 24 at 9:00
  • 1
    You have a nice example of the concept in the online TopoJSON editor geo.land. If you look at the default world map, you'll se that borders between countries appear as arc property only once. Then, when used as actual polygons describing border between two bordering countries, common border arc index appears in one country unsigned and in the other country with negative index, since polygon orientation goes the other way. – TomazicM Jun 24 at 12:02
  • 1
    GIS SE site policy requires focused questions. Now that you broadened your question to any mapping library, you risk it being closed as to broad. I would recommend you revert back to your original question. – TomazicM Jun 28 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.