|
@@ -192,7 +192,7 @@ function rndrSt(stat) {
|
192
|
192
|
.setLatLng(stat)
|
193
|
193
|
.setContent(con)
|
194
|
194
|
.openOn(map)
|
195
|
|
- .on('remove', function() {openedSt = -1; stUnHl(stat.id);});
|
|
195
|
+ .on('remove', function() {if (openedSt == stat.id) {openedSt = -1; stUnHl(stat.id)}});
|
196
|
196
|
}
|
197
|
197
|
|
198
|
198
|
function openSt(id) {req("s", "/stat?id=" + id, function(c) {rndrSt(c)});}
|
|
@@ -318,7 +318,7 @@ function rndrGr(grp, ll) {
|
318
|
318
|
.setLatLng(ll)
|
319
|
319
|
.setContent(con)
|
320
|
320
|
.openOn(map)
|
321
|
|
- .on('remove', function() {openedGr = -1; grUnHl(grp.id)});
|
|
321
|
+ .on('remove', function() {if (openedGr == grp.id) {openedGr = -1; grUnHl(grp.id)}});
|
322
|
322
|
}
|
323
|
323
|
|
324
|
324
|
function openGr(id, ll) {
|
|
@@ -374,9 +374,11 @@ map.addControl(L.control.attribution({
|
374
|
374
|
}));
|
375
|
375
|
|
376
|
376
|
map.on('popupopen', function(e) {
|
377
|
|
- var px = map.project(e.target._popup._latlng);
|
|
377
|
+ var z = Math.max(map.getZoom(), 16);
|
|
378
|
+ var px = map.project(e.target._popup._latlng, z);
|
378
|
379
|
px.y -= e.target._popup._container.clientHeight/2;
|
379
|
|
- map.panTo(map.unproject(px),{animate: true});
|
|
380
|
+
|
|
381
|
+ map.setView(map.unproject(px, z), z, {animate: true});
|
380
|
382
|
s();
|
381
|
383
|
});
|
382
|
384
|
|
|
@@ -504,8 +506,8 @@ function unselect(row) {
|
504
|
506
|
selectedRes = undefined;
|
505
|
507
|
if (!row) return;
|
506
|
508
|
delCl(row, "selres");
|
507
|
|
- if (row.stat) stUnHl(row.stat.i);
|
508
|
|
- if (row.group) grUnHl(row.group.i);
|
|
509
|
+ if (row.stat && row.stat.i != openedSt) stUnHl(row.stat.i);
|
|
510
|
+ if (row.group && row.group.i != openedGr) grUnHl(row.group.i);
|
509
|
511
|
}
|
510
|
512
|
|
511
|
513
|
function isSearchOpen() {
|
|
@@ -521,6 +523,7 @@ function s(q) {
|
521
|
523
|
if (!q) {
|
522
|
524
|
$('#si').value = "";
|
523
|
525
|
$("#sres").className = "";
|
|
526
|
+ $("#sres").innerHTML = "";
|
524
|
527
|
return;
|
525
|
528
|
}
|
526
|
529
|
|
|
@@ -550,6 +553,11 @@ function s(q) {
|
550
|
553
|
row.onmouseover = function(){select(this)};
|
551
|
554
|
row.onclick = function(){rowClick(this)};
|
552
|
555
|
|
|
556
|
+ var dist = $$('span');
|
|
557
|
+ addCl(dist, "dist");
|
|
558
|
+ dist.innerHTML = dstr(e.s ? e.s.g : e.g.g);
|
|
559
|
+ row.appendChild(dist);
|
|
560
|
+
|
553
|
561
|
if (e.v && e.v != e.name) {
|
554
|
562
|
var via = $$('span');
|
555
|
563
|
addCl(via, "via");
|
|
@@ -562,13 +570,21 @@ function s(q) {
|
562
|
570
|
)}, delay);
|
563
|
571
|
}
|
564
|
572
|
|
|
573
|
+function dstr(s) {
|
|
574
|
+ if (map.getBounds().contains(ll(s[0]))) return "";
|
|
575
|
+ var d = map.distance(map.getCenter(), ll(s[0]));
|
|
576
|
+ if (d < 500) return Math.round(d).toFixed(0) + "m";
|
|
577
|
+ if (d < 5000) return (d / 1000.0).toFixed(1) + "km";
|
|
578
|
+ return Math.round(d / 1000.0).toFixed(0) + "km";
|
|
579
|
+}
|
|
580
|
+
|
565
|
581
|
function kp(e) {
|
566
|
|
- if (e.keyCode == 40) {
|
|
582
|
+ if (e.keyCode == 40 || (!e.shiftKey && e.keyCode == 9)) {
|
567
|
583
|
var sels = $('.selres')
|
568
|
584
|
if (sels.length) select(sels[0].nextSibling);
|
569
|
585
|
else select($('.sres')[0]);
|
570
|
586
|
e.preventDefault();
|
571
|
|
- } else if (e.keyCode == 38) {
|
|
587
|
+ } else if (e.keyCode == 38 || (e.shiftKey && e.keyCode == 9)) {
|
572
|
588
|
var sels = $('.selres')
|
573
|
589
|
if (sels.length) {
|
574
|
590
|
if (sels[0].previousSibling) select(sels[0].previousSibling);
|