Skip to content

Commit

Permalink
Apply check on trailcoords in mapfunctions
Browse files Browse the repository at this point in the history
  • Loading branch information
Isthisanmol committed May 27, 2024
1 parent df0d05a commit efea7e8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/app/utils/mapFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,20 @@ function calculateZoomLevel(bounds, mapDim) {
* @return {array} The center coordinates of the trail.
*/
function findTrailCenter(shape) {

console.log('Finding trail center...', shape);
const trailCoords = shape?.features[0]?.geometry?.coordinates;

// Flatten the coordinates array for Polygon geometries
const flattenedCoords = trailCoords[0].flat();

let flattenedCoords;
if(Array.isArray(trailCoords[0][0][0])){
flattenedCoords = trailCoords[0].flat();
}else {
flattenedCoords = trailCoords[0];
}

// const flattenedCoords = trailCoords[0].flat();

const latitudes = flattenedCoords.map((coord) => coord[1]);
const longitudes = flattenedCoords.map((coord) => coord[0]);
Expand Down

0 comments on commit efea7e8

Please sign in to comment.