Closed ekbarber closed 7 years ago
Thanks for reporting this. Can you recommend a solution that is also backwards compatible? Or is object/ feature detection the way to go here?
@arthur-e Depends on how backwards compatible you'd like to be. If it's just with 0.7.7, you could use L.version to check if it's 0.7.7 or not. But that'll get complicated if you want to allow for versions prior to 0.7.7.
or you could, as you suggested, simply check if L.multiPolygon exists first, and if so, use that, otherwise use L.polygon.
Note that we'll likely have to take a similar approach for multiPolyline, as it looks like it too has been removed in 1.0.0
I can confirm that the fixes above work. I have just monkey patched our install until a fix is ready by doing:
Wkt.Wkt.prototype.construct.multipolygon = function (config) {
// Truncate the coordinates to remove the closing coordinate
var coords = this.trunc(this.components),
latlngs = this.coordsToLatLngs(coords, 2);
if (L.multiPolyline)
{
return L.multiPolyline(latlngs, config);
}
else
{
return L.polygon(latlngs, config);
}
};
Wkt.Wkt.prototype.construct.multilinestring = function (config) {
var coords = this.components,
latlngs = this.coordsToLatLngs(coords, 1);
if (L.multiPolygon)
{
return L.multiPolygon(latlngs, config);
}
else
{
return L.polygon(latlngs, config);
}
};
If you want I can send a pull request for it or you can just copy the above :)
@crash-dive Could you send a pull request, please?
With the release of Leaflet 1.0, L.multiPolygon is no longer a function, and therefore an error is thrown when Wicket is parsing a MULTIPOLYGON (L.multiPolygon is not a function).
It appears the new way to create a Multipolygon is to pass a multidimensional array to L.polygon (http://leafletjs.com/reference-1.0.0.html#polygon).