LatLngUtil.js 757 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * @class L.LatLngUtil
  3. * @aka LatLngUtil
  4. */
  5. L.LatLngUtil = {
  6. // Clones a LatLngs[], returns [][]
  7. // @method cloneLatLngs(LatLngs[]): L.LatLngs[]
  8. // Clone the latLng point or points or nested points and return an array with those points
  9. cloneLatLngs: function (latlngs) {
  10. var clone = [];
  11. for (var i = 0, l = latlngs.length; i < l; i++) {
  12. // Check for nested array (Polyline/Polygon)
  13. if (Array.isArray(latlngs[i])) {
  14. clone.push(L.LatLngUtil.cloneLatLngs(latlngs[i]));
  15. } else {
  16. clone.push(this.cloneLatLng(latlngs[i]));
  17. }
  18. }
  19. return clone;
  20. },
  21. // @method cloneLatLng(LatLng): L.LatLng
  22. // Clone the latLng and return a new LatLng object.
  23. cloneLatLng: function (latlng) {
  24. return L.latLng(latlng.lat, latlng.lng);
  25. }
  26. };