Skip to content

Commit 31f92dd

Browse files
fix ugc example, mapextend 增加movelayer判断
1 parent fec593a commit 31f92dd

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

examples/openlayers/ugc_resample.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ <h5 class="panel-title text-center">重采样</h5>
129129
var lineLayer = new ol.layer.Vector({
130130
source: lineSource,
131131
style: new ol.style.Style({
132-
stroke: new ol.style.Stroke(style)
132+
stroke: new ol.style.Stroke(style),
133+
fill: new ol.style.Fill({
134+
color: style.color
135+
})
133136
})
134137
});
135138
map.addLayer(lineLayer);

examples/openlayers/ugc_spatialRelationship.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,11 @@ <h5 class="panel-title text-center">空间关系</h5>
157157
source: polygonSource,
158158
style: new ol.style.Style({
159159
stroke: new ol.style.Stroke({
160-
color: style.color || 'blue',
160+
color: style.color || 'rgba(0, 0, 255, 0.6)',
161161
width: 3
162+
}),
163+
fill: new ol.style.Fill({
164+
color: style.color || 'rgba(0, 0, 255, 0.6)',
162165
})
163166
})
164167
});

src/mapboxgl/core/MapExtend.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ export var MapExtend = (function () {
9999
: this._moveToHandler(id, beforeId);
100100
return this;
101101
}
102-
if (this.style._layers[id]) {
102+
if (this.style._layers[id] && this.style._layers[beforeId]) {
103103
this.style.moveLayer(id, beforeId);
104104
this._update(true);
105-
return this;
106105
}
106+
return this;
107107
}
108108

109109
removeLayer(id) {
@@ -305,11 +305,13 @@ export var MapExtend = (function () {
305305
});
306306
}
307307
}
308-
if (layer && beforeLayer) {
309-
beforeLayer.parentNode.insertBefore(layer, beforeLayer);
310-
} else {
311-
//当没有传入beforeLayerID ,则默认将图层移动到最上面
312-
layer.parentNode.appendChild(layer);
308+
if (layer) {
309+
if (beforeLayer) {
310+
beforeLayer.parentNode.insertBefore(layer, beforeLayer);
311+
} else {
312+
//当没有传入beforeLayerID ,则默认将图层移动到最上面
313+
layer.parentNode.appendChild(layer);
314+
}
313315
}
314316
}
315317

0 commit comments

Comments
 (0)