detect boundary lat longs from given list of lat and long in angular

enter image description hereAm using here map. I have a list of objects which has all the latitude and longitude of a particular region from a map as below

//Texas points

let list = [
  { lat: 36.5098, lng: -103.0559 },
  { lat: 32.0456, lng: -103.0559 },
  { lat: 32.0456, lng: -106.6103 },
  { lat: 30.827, lng: -105.385 },
  { lat: 29.631, lng: -104.4622 },
  { lat: 29.018, lng: -103.1878 },
  { lat: 29.898, lng: -102.3528 },
  { lat: 27.3525, lng: -99.5403 },
  { lat: 25.9106, lng: -97.2943 },
  { lat: 28.3933, lng: -96.5692 },
  { lat: 29.6994, lng: -93.8665 },
  { lat: 33.5523, lng: -94.0423 },
  { lat: 34.5897, lng: -99.9969 },
  { lat: 36.4848, lng: -99.9969 },
  { lat: 36.5098, lng: -103.0559 },
  { lat: 33.3507, lng: -98.283 },
  { lat: 32.4281, lng: -94.8553 },
  { lat: 26.8358, lng: -98.0853 },
  { lat: 30.9512, lng: -98.5247 },
  { lat: 31.4773, lng: -105.2484 }
];

Is there a way to find out the boundary points from the above list. Any ideas how to approach this. Thanks in advance.

Answer

function addPolygonToMap(map) {
  let str = [];
  for (let i = 0; i < list.length; i++) {
    str.push(parseFloat(list[i].lat));
    str.push(parseFloat(list[i].lng));
    str.push(0);
  }

  var geoStrip = new H.geo.Strip([...str], "values lat lng alt");
  map.addObject(
    new H.map.Polygon(geoStrip, {
      style: {
        fillColor: "red",
        strokeColor: "#829",
        lineWidth: 4
      }
    })
  );

}

Leave a Reply

Your email address will not be published. Required fields are marked *