mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-21 15:56:56 +02:00
@@ -85,7 +85,3 @@ iD.geo.pathLength = function(path) {
|
||||
}
|
||||
return length;
|
||||
};
|
||||
|
||||
iD.geo.metersToCoordinates = function(loc, vector) {
|
||||
return [vector[1] / 111200, vector[0] / 111200 / Math.abs(Math.cos(loc[1]))];
|
||||
};
|
||||
|
||||
@@ -33,5 +33,13 @@ _.extend(iD.geo.Extent.prototype, {
|
||||
obj[0][1] <= this[1][1] &&
|
||||
obj[1][0] >= this[0][0] &&
|
||||
obj[1][1] >= this[0][1];
|
||||
},
|
||||
|
||||
padByMeters: function(meters) {
|
||||
var dLat = meters / 111200,
|
||||
dLon = meters / 111200 / Math.abs(Math.cos(this.center()[1]));
|
||||
return iD.geo.Extent(
|
||||
[this[0][0] - dLon, this[0][1] - dLat],
|
||||
[this[1][0] + dLon, this[1][1] + dLat]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -5,7 +5,10 @@ iD.ui.Geolocate = function(map) {
|
||||
}
|
||||
|
||||
function success(position) {
|
||||
map.center([position.coords.longitude, position.coords.latitude]);
|
||||
var extent = iD.geo.Extent([position.coords.longitude, position.coords.latitude])
|
||||
.padByMeters(position.coords.accuracy);
|
||||
|
||||
map.centerZoom(extent.center(), Math.min(20, map.extentZoom(extent)));
|
||||
}
|
||||
|
||||
function error() { }
|
||||
|
||||
@@ -12,10 +12,7 @@ iD.ui.preset.address = function(field, context) {
|
||||
|
||||
var extent = entity.extent(context.graph()),
|
||||
l = extent.center(),
|
||||
dist = iD.geo.metersToCoordinates(l, [200, 200]),
|
||||
box = iD.geo.Extent(
|
||||
[extent[0][0] - dist[0], extent[0][1] - dist[1]],
|
||||
[extent[1][0] + dist[0], extent[1][1] + dist[1]]);
|
||||
box = iD.geo.Extent(l).padByMeters(200);
|
||||
|
||||
return context.intersects(box)
|
||||
.filter(isAddressable)
|
||||
|
||||
Reference in New Issue
Block a user