Fix vector hiding at high zooms, fix hash-default interaction.

This commit is contained in:
Tom MacWright
2012-11-16 15:27:14 -05:00
parent 854aa65e6e
commit 1a68cab563
7 changed files with 27 additions and 54 deletions
+5 -4
View File
@@ -15,7 +15,7 @@
+&nbsp;Place</button><button id='road'>
+&nbsp;Road</button><button id='area'>
+&nbsp;Area</button><button class='mini' id='undo'>
&larr;<small></small></button><button class='mini' id='redo'>
&larr;<small>&nbsp;</small></button><button class='mini' id='redo'>
&rarr;</button><input type='text' id='geocode-location' placeholder='find a place' />
<div class='messages'></div>
<button id='save'>Save</button>
@@ -65,13 +65,14 @@
<script type='text/javascript' src='js/iD/Connection.js'></script>
<script>
var map = iD.Map(document.getElementById('map')).setZoom(19).setCenter({
var map = iD.Map(document.getElementById('map'));
var m = d3.select('#map');
var hash = iD.Hash().map(map);
if (!hash.hadHash) map.setZoom(19).setCenter({
lat: 48.83724,
lon: 2.35266
});
var m = d3.select('#map');
iD.Hash().map(map);
var controller = iD.Controller(map);
d3.selectAll('button#place').on('click', function() {
View File
View File
+11 -6
View File
@@ -36,7 +36,7 @@ iD.Map = function(elem) {
.on('drag', function(entity) {
var to = projection.invert([d3.event.x, d3.event.y]);
history.replace(iD.operations.move(entity, to));
drawVector();
redraw();
})
.on('dragend', map.update),
nodeline = function(d) {
@@ -177,6 +177,13 @@ iD.Map = function(elem) {
}
function hideHandles() { hit_g.selectAll('rect.handle').remove(); }
function hideVector() {
fill_g.selectAll('*').remove();
stroke_g.selectAll('*').remove();
casing_g.selectAll('*').remove();
text_g.selectAll('*').remove();
hit_g.selectAll('*').remove();
}
function drawFills(areas) {
var fills = fill_g.selectAll('path').data(areas, key);
@@ -361,7 +368,7 @@ iD.Map = function(elem) {
var hadSelection = !!selection;
selection = null;
if (hadSelection) {
drawVector();
redraw();
hideInspector();
}
}
@@ -372,7 +379,7 @@ iD.Map = function(elem) {
d3.select('.inspector-wrap')
.style('display', 'block')
.datum(d).call(inspector);
drawVector();
redraw();
}
inspector.on('change', function(d, tags) {
@@ -398,7 +405,6 @@ iD.Map = function(elem) {
fastPan(d3.mouse(document.body), translateStart);
} else {
redraw();
download();
translateStart = null;
}
}
@@ -419,7 +425,7 @@ iD.Map = function(elem) {
function redraw() {
dispatch.move(map);
tileclient.redraw();
if (getZoom() > 13) {
if (getZoom() > 16) {
download();
drawVector();
} else {
@@ -493,7 +499,6 @@ iD.Map = function(elem) {
projection.translate(t);
zoombehavior.translate(projection.translate());
drawVector();
redraw();
return map;
}
-38
View File
@@ -1,38 +0,0 @@
function clickCancelProvider() {
var event = d3.dispatch('click', 'dblclick');
function cc(selection) {
var down,
tolerance = 5,
last,
wait = null;
// euclidean distance
function dist(a, b) {
return Math.sqrt(Math.pow(a[0] - b[0], 2), Math.pow(a[1] - b[1], 2));
}
selection.on('mousedown', function() {
down = [d3.event.pageX, d3.event.pageY];
last = +new Date();
});
selection.on('mouseup', function() {
var up = [d3.event.pageX, d3.event.pageY];
if (dist(down, up) > tolerance) {
console.log(down, up);
return;
} else {
if (wait) {
window.clearTimeout(wait);
wait = null;
event.dblclick.apply(selection, d3.event);
} else {
wait = window.setTimeout((function(e) {
return function() {
event.click.apply(selection, e);
wait = null;
};
})(d3.event), 300);
}
}
});
}
return d3.rebind(cc, event, 'on');
}
+10 -5
View File
@@ -1,8 +1,9 @@
iD.Hash = function() {
var hash = {},
s0, // cached location.hash
lat = 90 - 1e-8, // allowable latitude range
map;
s0, // cached location.hash
lat = 90 - 1e-8, // allowable latitude range
hadHash,
map;
var qs = function(a,b,c,d,e){for(b=/[?&]?([^=]+)=([^&]*)/g,c={},e=decodeURIComponent;d=b.exec(a.replace(/\+/g,' '));c[e(d[1])]=e(d[2]));return c;};
@@ -47,11 +48,15 @@ iD.Hash = function() {
if (x) {
map.on("move", move);
window.addEventListener("hashchange", hashchange, false);
if (location.hash) hashchange();
else move();
if (location.hash) {
hashchange();
hadHash = true;
}
}
return hash;
};
hash.hadHash = hadHash;
return hash;
};
+1 -1
View File
@@ -1,5 +1,5 @@
// a minimal map tile client, to be turned on and off etc.
iD.Tiles = function(selection, projection, dimensions) {
iD.Tiles = function(selection, projection) {
var tiles = {}, dimensions;
// derive the url of a 'quadkey' style tile from a coordinate object