0

how can i show Delta Longitude and Latitude (vector change) in google map,is there anyone worked with this before?? P.S:Delta Longitude and Latitude are different than longitude and latitude.

  • 1
    Please remember to show example code and what you've tried to solve the problem. Also show your expected result. – Michael L. Mar 30 '17 at 15:23
  • thanks for your answer Michael..at the moment i have no idea how to implement this..i'm making some researches how to do that. –  Mar 31 '17 at 08:43

1 Answers1

1

You may refer with this thread. Given an array of coordinates coords, this function returns the region (lat, lng and deltas) to contain those coordinates.

export function getRegionForCoordinates(points) {
  // points should be an array of { latitude: X, longitude: Y }
  let minX, maxX, minY, maxY;

  // init first point
  ((point) => {
    minX = point.latitude;
    maxX = point.latitude;
    minY = point.longitude;
    maxY = point.longitude;
  })(points[0]);

  // calculate rect
  points.map((point) => {
    minX = Math.min(minX, point.latitude);
    maxX = Math.max(maxX, point.latitude);
    minY = Math.min(minY, point.longitude);
    maxY = Math.max(maxY, point.longitude);
  });

  const midX = (minX + maxX) / 2;
  const midY = (minY + maxY) / 2;
  const deltaX = (maxX - minX);
  const deltaY = (maxY - minY);

  return {
    latitude: midX,
    longitude: midY,
    latitudeDelta: deltaX,
    longitudeDelta: deltaY
  };
}

Here are some related threads:

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59
  • thanks a lot abielita for your answer ..i will try it and i will get u back –  Mar 31 '17 at 09:36
  • By the way, i have already delta longitude and latitude calculated i want just to show them in the map..thats all –  Mar 31 '17 at 09:38