Added zipcode reverse function to get zipcode from latlng.
This commit is contained in:
parent
5ca70c7870
commit
0e1c1f16cb
@ -61511,9 +61511,39 @@ class Zip2LatLng {
|
||||
lng: (r[1] / 100000) * -1,
|
||||
city: c[r[2]],
|
||||
state: s[r[3]],
|
||||
abbreviation: a[r[4]]
|
||||
abbreviation: a[r[4]],
|
||||
zipcode: zip
|
||||
};
|
||||
}
|
||||
|
||||
static reverse(lat, lng) {
|
||||
var b = Number.MAX_VALUE;
|
||||
var r = null;
|
||||
var zip = 0;
|
||||
for (var i = 0; i < z.length; i++) {
|
||||
if (z[i]) {
|
||||
var d = Math.abs(((z[i][1] / 100000) * -1) - lng) + Math.abs((z[i][0] / 100000) - lat);
|
||||
if (d <= b) {
|
||||
r = z[i];
|
||||
zip = i;
|
||||
b = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (r) {
|
||||
return {
|
||||
lat: r[0] / 100000,
|
||||
lng: (r[1] / 100000) * -1,
|
||||
city: c[r[2]],
|
||||
state: s[r[3]],
|
||||
abbreviation: a[r[4]],
|
||||
zipcode: zip
|
||||
};
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.Zip2LatLng = Zip2LatLng;
|
||||
|
Loading…
x
Reference in New Issue
Block a user