Skip to content

Commit 69e7d2c

Browse files
Merge pull request #262 from jonataswalker/261-duplicate-callback
fix: single emitter instance
2 parents 20eb729 + 0e13324 commit 69e7d2c

File tree

7 files changed

+621
-559
lines changed

7 files changed

+621
-559
lines changed

index.html

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,48 @@
1111
<title>Custom Context Menu for Openlayers</title>
1212
<style>
1313
html,
14-
body,
15-
#map {
16-
width: 100%;
17-
height: 100%;
18-
overflow: hidden;
19-
}
20-
2114
body {
15+
margin: 0;
16+
height: 100%;
2217
font: 1em/1.5 BlinkMacSystemFont, -apple-system, 'Segoe UI', 'Roboto', 'Oxygen',
2318
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 'Helvetica',
2419
'Arial', sans-serif;
2520
color: #222;
2621
font-weight: 400;
2722
}
23+
.main-container {
24+
height: 100%;
25+
display: flex;
26+
}
27+
28+
.left-container {
29+
flex: 1 1 0;
30+
padding: 5px;
31+
}
2832

29-
#map {
30-
position: absolute;
31-
z-index: 1;
32-
top: 0;
33-
bottom: 0;
33+
.right-container {
34+
flex: 1 1 0;
35+
display: flex;
36+
flex-direction: column;
37+
padding: 5px;
38+
}
39+
#map1,
40+
#map2 {
41+
width: 100%;
42+
height: 100%;
3443
}
3544
</style>
3645
</head>
3746

3847
<body>
39-
<div id="map"></div>
48+
<div class="main-container">
49+
<div class="left-container">
50+
<div id="map1"></div>
51+
</div>
52+
<div class="right-container">
53+
<div id="map2"></div>
54+
</div>
55+
</div>
4056
<script type="module">
4157
import Map from 'ol/Map.js';
4258
import View from 'ol/View.js';
@@ -49,13 +65,21 @@
4965
import { Tile as TileLayer, Vector as VectorLayer } from 'ol/layer.js';
5066
import ContextMenu from './src/main.ts';
5167

52-
const view = new View({ center: [0, 0], zoom: 2 });
5368
const vectorLayer = new VectorLayer({ source: new VectorSource() });
69+
5470
const map = new Map({
55-
view,
56-
target: 'map',
71+
view: new View({ center: [0, 0], zoom: 2 }),
72+
target: 'map1',
5773
layers: [new TileLayer({ source: new OSM() }), vectorLayer],
5874
});
75+
const map2 = new Map({
76+
view: new View({ center: [0, 0], zoom: 2 }),
77+
target: 'map2',
78+
layers: [
79+
new TileLayer({ source: new OSM() }),
80+
new VectorLayer({ source: new VectorSource() }),
81+
],
82+
});
5983

6084
const pinIcon =
6185
'https://cdn.jsdelivr.net/gh/jonataswalker/ol-contextmenu@604befc46d737d814505b5d90fc171932f747043/examples/img/pin_drop.png';
@@ -154,9 +178,14 @@
154178
const contextmenu = new ContextMenu({
155179
width: 200,
156180
defaultItems: true,
157-
items,
158181
});
182+
const contextmenu2 = new ContextMenu({
183+
width: 200,
184+
defaultItems: true,
185+
});
186+
159187
map.addControl(contextmenu);
188+
map2.addControl(contextmenu2);
160189

161190
const removeMarkerItem = {
162191
text: 'Remove this Marker',

0 commit comments

Comments
 (0)