Skip to content

Closing polygon vertice coordinates not identical to starting vertice coordinates? #867

Discussion options

You must be logged in to vote

Hi Rex,

with _latlngs you are useing the LatLng definition of Leaflet. (Same but public method would be .getLatLngs()). In Leaflet the first and last positions are not equivalent.
But you can convert it to geojson with .toGeoJSON()

GeoJSON definition:

For type "Polygon", the "coordinates" member must be an array of LinearRing coordinate arrays.

(2.1.6 Polygon)

A LinearRing is closed LineString with 4 or more positions. The first and last positions are equivalent (they represent equivalent points).

(2.1.4. LineString)

The default export type for Leaflet is GeoJSON, so there is also a way to import it with L.geoJSON()

Example:

Export:

var poly = L.polygon([yourCoords}).addTo(map);
var g…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rexrobichaux
Comment options

Answer selected by Falke-Design
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants