mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
d3 style map.extent()
This commit is contained in:
@@ -103,7 +103,7 @@ iD.Map = function(elem, connection) {
|
||||
if (surface.style(transformProp) != 'none') return;
|
||||
var z = map.zoom(),
|
||||
all = [], ways = [], areas = [], points = [], waynodes = [],
|
||||
extent = getExtent(),
|
||||
extent = map.extent(),
|
||||
graph = map.history.graph();
|
||||
|
||||
if (!only) {
|
||||
@@ -448,10 +448,6 @@ iD.Map = function(elem, connection) {
|
||||
return map;
|
||||
}
|
||||
|
||||
function getExtent() {
|
||||
return [projection.invert([0, 0]), projection.invert(dimensions)];
|
||||
}
|
||||
|
||||
function pointLocation(p) {
|
||||
var translate = projection.translate(),
|
||||
scale = projection.scale();
|
||||
@@ -494,7 +490,7 @@ iD.Map = function(elem, connection) {
|
||||
map.zoomIn = function() { return map.zoom(Math.ceil(map.zoom() + 1)); };
|
||||
map.zoomOut = function() { return map.zoom(Math.floor(map.zoom() - 1)); };
|
||||
|
||||
function center(loc) {
|
||||
map.center = function(loc) {
|
||||
if (!arguments.length) {
|
||||
return projection.invert(pxCenter());
|
||||
} else {
|
||||
@@ -507,21 +503,21 @@ iD.Map = function(elem, connection) {
|
||||
redraw();
|
||||
return map;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
map.extent = function() {
|
||||
return [projection.invert([0, 0]), projection.invert(dimensions)];
|
||||
};
|
||||
|
||||
function flush() {
|
||||
apiTilesLoaded = {};
|
||||
}
|
||||
|
||||
map.download = download;
|
||||
map.getExtent = getExtent;
|
||||
|
||||
map.selectEntity = selectEntity;
|
||||
|
||||
map.background = background;
|
||||
map.center = center;
|
||||
map.centre = center;
|
||||
|
||||
map.projection = projection;
|
||||
map.size = setSize;
|
||||
|
||||
|
||||
@@ -34,8 +34,8 @@ describe('Map', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getCenter', function() {
|
||||
it('reports center', function() {
|
||||
describe('#center', function() {
|
||||
it('gets and sets center', function() {
|
||||
expect(map.center([0, 0])).toEqual(map);
|
||||
expect(map.center()).toEqual([0, 0]);
|
||||
expect(map.center([10, 15])).toEqual(map);
|
||||
@@ -44,12 +44,12 @@ describe('Map', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getExtent', function() {
|
||||
describe('#extent', function() {
|
||||
it('reports extent', function() {
|
||||
expect(map.size([100, 100])).toEqual(map);
|
||||
expect(map.center([0, 0])).toEqual(map);
|
||||
expect(map.getExtent()[0][0]).toBeCloseTo(-36);
|
||||
expect(map.getExtent()[1][0]).toBeCloseTo(36);
|
||||
expect(map.extent()[0][0]).toBeCloseTo(-36);
|
||||
expect(map.extent()[1][0]).toBeCloseTo(36);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user