Open page, for example, and type the following commands into web browser's console and copy output to file:
script = document.createElement('script');
document.head.appendChild(script);
script.onload = function () {
polygons = [];
adminLayer.forEach(function (polygon) {
linearRing = [];
polygon.getPath().b.forEach(function (vertex, index) {
linearRing.push([vertex.lng(), vertex.lat()]);
});
firstCoordinate = linearRing[0];
lastCoordinate = linearRing.slice(-1)[0];
if ((firstCoordinate[0] !== lastCoordinate[0]) ||
(firstCoordinate[1] !== lastCoordinate[1])) {
linearRing.push(firstCoordinate);
}
polygons.push(
new ol.Feature({
geometry: new ol.geom.Polygon([linearRing]),
name: polygon.name
})
);
});
geojson = new ol.format.GeoJSON();
console.log(geojson.writeFeatures(polygons));
};
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/ol3/4.2.0/ol.js';
I get an error when trying to execute the script:
Is the script working now, or have citypopulation.de developers changed something?