From 53c5a0b13113980fcabc8ad944a5d2d828591f5a Mon Sep 17 00:00:00 2001 From: Leo Date: Sun, 11 Jun 2023 08:01:05 +0300 Subject: [PATCH] Fixed linting --- src/staticmaps.js | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/staticmaps.js b/src/staticmaps.js index d2cf374..f68ca18 100644 --- a/src/staticmaps.js +++ b/src/staticmaps.js @@ -103,6 +103,59 @@ class StaticMaps { this.text.push(new Text(options)); } + // geoJSON types according to RFC 7946 + addGeoJSON(options) { + switch (options.geoJSON.type) { + case 'Point': + this.addMarker({ + ...options.markerOptions, + coord: options.geoJSON.coordinates, + }); + break; + case 'MultiPoint': + options.geoJSON.coordinates.forEach((coordinate) => { + this.addMarker({ ...options.markerOptions, coord: coordinate }); + }); + break; + case 'LineString': + this.addLine({ + ...options.lineOptions, + coords: options.geoJSON.coordinates, + }); + break; + case 'MultiLineString': + options.geoJSON.coordinates.forEach((coordinate) => { + this.addLine({ ...options.lineOptions, coords: coordinate }); + }); + break; + case 'Polygon': + this.addPolygon({ + ...options.polygonOptions, + coords: options.geoJSON.coordinates, + }); + break; + case 'MultiPolygon': + this.addMultiPolygon({ + ...options.polygonOptions, + coords: options.geoJSON.coordinates, + }); + break; + case 'GeometryCollection': + options.geoJSON.geometries.forEach((geometry) => { + this.addGeoJSON({ ...options, geoJSON: geometry }); + }); + break; + case 'Feature': + this.addGeoJSON({ ...options, geoJSON: options.geoJSON.geometry }); + break; + case 'FeatureCollection': + options.geoJSON.features.forEach((feature) => { + this.addGeoJSON({ ...options, geoJSON: feature }); + }); + break; + } + } + /** * Render static map with all map features that were added to map before */