Skip to content

Commit ecb2907

Browse files
committed
update
1 parent 5a00989 commit ecb2907

File tree

2 files changed

+55
-18
lines changed

2 files changed

+55
-18
lines changed

geojson-editor/index.html

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,40 @@
1717
--size-word: 14px;
1818
}
1919

20+
.maplibregl-ctrl-group {
21+
filter: invert(90%);
22+
}
23+
24+
.maplibregl-ctrl-scale {
25+
filter: invert(90%);
26+
}
27+
28+
.maplibregl-ctrl-top-center {
29+
top: 0;
30+
left: 50%;
31+
transform: translateX(-50%);
32+
pointer-events: none;
33+
position: absolute;
34+
z-index: 2;
35+
}
36+
37+
.maplibregl-ctrl-top-center>.maplibregl-ctrl {
38+
margin: 10px 0 0 0;
39+
}
40+
41+
.maplibregl-ctrl-bottom-center {
42+
bottom: 0;
43+
left: 50%;
44+
transform: translateX(-50%);
45+
pointer-events: none;
46+
position: absolute;
47+
z-index: 2;
48+
}
49+
50+
.maplibregl-ctrl-bottom-center>.maplibregl-ctrl {
51+
margin: 0 0 10px 0;
52+
}
53+
2054
body {
2155
margin: 0;
2256
height: 100vh;
@@ -27,14 +61,6 @@
2761
height: 100%;
2862
width: 100%;
2963
}
30-
31-
.maplibregl-ctrl-group{
32-
filter: invert(100%);
33-
}
34-
35-
.maplibregl-ctrl-scale{
36-
filter: invert(90%);
37-
}
3864
</style>
3965
</head>
4066

geojson-editor/src/App.vue

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,35 @@ function handleMapLoaded(map: maplibregl.Map) {
114114
drawManager,
115115
onUpload: (features: Array<TIdentityGeoJSONFeature>) => glManager.add(...features),
116116
onDownload: () => glManager.fc
117-
}, "top-left");
117+
}, "top-center");
118118
createMapControl(map, Measurer, { measureManager }, 'top-left');
119119
}
120120
121-
function createMapControl(map: maplibregl.Map, component: Component, data?: Record<string, unknown>, position: maplibregl.ControlPosition = 'top-right') {
121+
function createMapControl(map: maplibregl.Map, component: Component, data?: Record<string, unknown>, position: maplibregl.ControlPosition | "top-center" | "bottom-center" = 'top-right') {
122122
const div = document.createElement('div');
123123
div.classList.add("maplibregl-ctrl");
124-
125124
createApp(component, data).mount(div);
126125
127-
map.addControl({
128-
onAdd() {
129-
return div;
130-
},
131-
onRemove() {
132-
div.remove();
126+
if (position !== 'top-center' && position !== "bottom-center")
127+
map.addControl({
128+
onAdd() {
129+
return div;
130+
},
131+
onRemove() {
132+
div.remove();
133+
}
134+
}, position);
135+
136+
else{
137+
let container = document.querySelector(`.maplibregl-ctrl-${position}`);
138+
if(!container){
139+
container = document.createElement('div');
140+
container.classList.add(`maplibregl-ctrl-${position}`);
141+
map._controlContainer.append(container);
133142
}
134-
}, position);
143+
144+
container.append(div);
145+
}
135146
}
136147
</script>
137148

0 commit comments

Comments
 (0)