Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
meshviewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
infrastruktur
meshviewer
Commits
6505f549
Commit
6505f549
authored
Feb 5, 2017
by
Xaver Maierhofer
Committed by
Geno
Feb 5, 2017
Browse files
Options
Downloads
Patches
Plain Diff
[TASK] Cleanup duplicate code
- map buttons - layer getTileBBox
parent
59a73a3f
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/map.js
+13
-33
13 additions, 33 deletions
lib/map.js
lib/map/clientlayer.js
+3
-10
3 additions, 10 deletions
lib/map/clientlayer.js
lib/map/labelslayer.js
+3
-10
3 additions, 10 deletions
lib/map/labelslayer.js
lib/utils/helper.js
+6
-0
6 additions, 0 deletions
lib/utils/helper.js
with
25 additions
and
53 deletions
lib/map.js
+
13
−
33
View file @
6505f549
...
@@ -9,7 +9,7 @@ define(['map/clientlayer', 'map/labelslayer',
...
@@ -9,7 +9,7 @@ define(['map/clientlayer', 'map/labelslayer',
zoomControl
:
false
zoomControl
:
false
};
};
var
Locate
Button
=
L
.
Control
.
extend
({
var
Button
Base
=
L
.
Control
.
extend
({
options
:
{
options
:
{
position
:
'
bottomright
'
position
:
'
bottomright
'
},
},
...
@@ -22,6 +22,17 @@ define(['map/clientlayer', 'map/labelslayer',
...
@@ -22,6 +22,17 @@ define(['map/clientlayer', 'map/labelslayer',
this
.
f
=
f
;
this
.
f
=
f
;
},
},
update
:
function
()
{
this
.
button
.
classList
.
toggle
(
'
active
'
,
this
.
active
);
},
set
:
function
(
v
)
{
this
.
active
=
v
;
this
.
update
();
}
});
var
LocateButton
=
ButtonBase
.
extend
({
onAdd
:
function
()
{
onAdd
:
function
()
{
var
button
=
L
.
DomUtil
.
create
(
'
button
'
,
'
ion-locate shadow
'
);
var
button
=
L
.
DomUtil
.
create
(
'
button
'
,
'
ion-locate shadow
'
);
button
.
setAttribute
(
'
data-tooltip
'
,
_
.
t
(
'
button.tracking
'
));
button
.
setAttribute
(
'
data-tooltip
'
,
_
.
t
(
'
button.tracking
'
));
...
@@ -33,33 +44,12 @@ define(['map/clientlayer', 'map/labelslayer',
...
@@ -33,33 +44,12 @@ define(['map/clientlayer', 'map/labelslayer',
return
button
;
return
button
;
},
},
update
:
function
()
{
this
.
button
.
classList
.
toggle
(
'
active
'
,
this
.
active
);
},
set
:
function
(
v
)
{
this
.
active
=
v
;
this
.
update
();
},
onClick
:
function
()
{
onClick
:
function
()
{
this
.
f
(
!
this
.
active
);
this
.
f
(
!
this
.
active
);
}
}
});
});
var
CoordsPickerButton
=
L
.
Control
.
extend
({
var
CoordsPickerButton
=
ButtonBase
.
extend
({
options
:
{
position
:
'
bottomright
'
},
active
:
false
,
button
:
undefined
,
initialize
:
function
(
f
,
o
)
{
L
.
Util
.
setOptions
(
this
,
o
);
this
.
f
=
f
;
},
onAdd
:
function
()
{
onAdd
:
function
()
{
var
button
=
L
.
DomUtil
.
create
(
'
button
'
,
'
ion-pin shadow
'
);
var
button
=
L
.
DomUtil
.
create
(
'
button
'
,
'
ion-pin shadow
'
);
button
.
setAttribute
(
'
data-tooltip
'
,
_
.
t
(
'
button.location
'
));
button
.
setAttribute
(
'
data-tooltip
'
,
_
.
t
(
'
button.location
'
));
...
@@ -73,20 +63,10 @@ define(['map/clientlayer', 'map/labelslayer',
...
@@ -73,20 +63,10 @@ define(['map/clientlayer', 'map/labelslayer',
return
button
;
return
button
;
},
},
update
:
function
()
{
this
.
button
.
classList
.
toggle
(
'
active
'
,
this
.
active
);
},
set
:
function
(
v
)
{
this
.
active
=
v
;
this
.
update
();
},
onClick
:
function
(
e
)
{
onClick
:
function
(
e
)
{
L
.
DomEvent
.
stopPropagation
(
e
);
L
.
DomEvent
.
stopPropagation
(
e
);
this
.
f
(
!
this
.
active
);
this
.
f
(
!
this
.
active
);
}
}
});
});
function
mkMarker
(
dict
,
iconFunc
,
router
)
{
function
mkMarker
(
dict
,
iconFunc
,
router
)
{
...
...
This diff is collapsed.
Click to expand it.
lib/map/clientlayer.js
+
3
−
10
View file @
6505f549
define
([
'
leaflet
'
],
define
([
'
leaflet
'
,
'
helper
'
],
function
(
L
)
{
function
(
L
,
helper
)
{
'
use strict
'
;
'
use strict
'
;
return
L
.
TileLayer
.
Canvas
.
extend
({
return
L
.
TileLayer
.
Canvas
.
extend
({
...
@@ -13,13 +13,6 @@ define(['leaflet'],
...
@@ -13,13 +13,6 @@ define(['leaflet'],
this
.
redraw
();
this
.
redraw
();
},
},
drawTile
:
function
(
canvas
,
tilePoint
)
{
drawTile
:
function
(
canvas
,
tilePoint
)
{
function
getTileBBox
(
s
,
map
,
tileSize
,
margin
)
{
var
tl
=
map
.
unproject
([
s
.
x
-
margin
,
s
.
y
-
margin
]);
var
br
=
map
.
unproject
([
s
.
x
+
margin
+
tileSize
,
s
.
y
+
margin
+
tileSize
]);
return
[
br
.
lat
,
tl
.
lng
,
tl
.
lat
,
br
.
lng
];
}
if
(
!
this
.
data
)
{
if
(
!
this
.
data
)
{
return
;
return
;
}
}
...
@@ -29,7 +22,7 @@ define(['leaflet'],
...
@@ -29,7 +22,7 @@ define(['leaflet'],
var
map
=
this
.
_map
;
var
map
=
this
.
_map
;
var
margin
=
50
;
var
margin
=
50
;
var
bbox
=
getTileBBox
(
s
,
map
,
tileSize
,
margin
);
var
bbox
=
helper
.
getTileBBox
(
s
,
map
,
tileSize
,
margin
);
var
nodes
=
this
.
data
.
search
(
bbox
);
var
nodes
=
this
.
data
.
search
(
bbox
);
...
...
This diff is collapsed.
Click to expand it.
lib/map/labelslayer.js
+
3
−
10
View file @
6505f549
define
([
'
leaflet
'
,
'
rbush
'
],
define
([
'
leaflet
'
,
'
rbush
'
,
'
helper
'
],
function
(
L
,
rbush
)
{
function
(
L
,
rbush
,
helper
)
{
'
use strict
'
;
'
use strict
'
;
var
labelLocations
=
[[
'
left
'
,
'
middle
'
,
0
/
8
],
var
labelLocations
=
[[
'
left
'
,
'
middle
'
,
0
/
8
],
...
@@ -188,13 +188,6 @@ define(['leaflet', 'rbush'],
...
@@ -188,13 +188,6 @@ define(['leaflet', 'rbush'],
this
.
redraw
();
this
.
redraw
();
},
},
drawTile
:
function
(
canvas
,
tilePoint
,
zoom
)
{
drawTile
:
function
(
canvas
,
tilePoint
,
zoom
)
{
function
getTileBBox
(
s
,
map
,
tileSize
,
margin
)
{
var
tl
=
map
.
unproject
([
s
.
x
-
margin
,
s
.
y
-
margin
]);
var
br
=
map
.
unproject
([
s
.
x
+
margin
+
tileSize
,
s
.
y
+
margin
+
tileSize
]);
return
[
br
.
lat
,
tl
.
lng
,
tl
.
lat
,
br
.
lng
];
}
if
(
!
this
.
labels
)
{
if
(
!
this
.
labels
)
{
return
;
return
;
}
}
...
@@ -212,7 +205,7 @@ define(['leaflet', 'rbush'],
...
@@ -212,7 +205,7 @@ define(['leaflet', 'rbush'],
return
{
p
:
p
,
label
:
d
.
label
};
return
{
p
:
p
,
label
:
d
.
label
};
}
}
var
bbox
=
getTileBBox
(
s
,
map
,
tileSize
,
this
.
margin
);
var
bbox
=
helper
.
getTileBBox
(
s
,
map
,
tileSize
,
this
.
margin
);
var
labels
=
this
.
labels
.
search
(
bbox
).
map
(
projectNodes
);
var
labels
=
this
.
labels
.
search
(
bbox
).
map
(
projectNodes
);
...
...
This diff is collapsed.
Click to expand it.
lib/utils/helper.js
+
6
−
0
View file @
6505f549
...
@@ -232,5 +232,11 @@ define({
...
@@ -232,5 +232,11 @@ define({
}
}
return
p
;
return
p
;
},
getTileBBox
:
function
getTileBBox
(
s
,
map
,
tileSize
,
margin
)
{
var
tl
=
map
.
unproject
([
s
.
x
-
margin
,
s
.
y
-
margin
]);
var
br
=
map
.
unproject
([
s
.
x
+
margin
+
tileSize
,
s
.
y
+
margin
+
tileSize
]);
return
[
br
.
lat
,
tl
.
lng
,
tl
.
lat
,
br
.
lng
];
}
}
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment