Skip to content

Commit 3a5421c

Browse files
committed
fix 修复例子报错
1 parent 7376e8e commit 3a5421c

File tree

6 files changed

+273
-244
lines changed

6 files changed

+273
-244
lines changed

examples/mapboxgl/ugc_isIntersectRegionWithRect.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ <h5 class="panel-title text-center">面与矩形相交检测</h5>
135135
}
136136

137137
function search() {
138+
clearLayer();
138139
let intersectCount;
139140
var geometryAnalysis = new mapboxgl.supermap.GeometryAnalysis();
140141
[polygon1, polygon2].forEach((polygon) => {
@@ -162,6 +163,16 @@ <h5 class="panel-title text-center">面与矩形相交检测</h5>
162163
});
163164
}
164165

166+
function clearLayer() {
167+
if (!map) {
168+
return;
169+
}
170+
if (map.getLayer('fill3')) {
171+
map.removeLayer('fill3');
172+
map.removeSource('fill3');
173+
}
174+
}
175+
165176
initMap(url).then((map) => {
166177
addFeatures();
167178
});

examples/mapboxgl/ugc_pointPositon.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ <h5 class="panel-title text-center">点线关系</h5>
257257
map.removeLayer('line1');
258258
map.removeSource('line1');
259259
}
260+
if (map.getLayer('nearestPoint')) {
261+
map.removeLayer('nearestPoint');
262+
map.removeSource('nearestPoint');
263+
}
260264
}
261265
initMap(url).then((map) => {
262266
addFeatures();

0 commit comments

Comments
 (0)