Skip to content

Commit d1fcb16

Browse files
committed
优化例子 fix sonar
1 parent 256be46 commit d1fcb16

File tree

5 files changed

+30
-35
lines changed

5 files changed

+30
-35
lines changed

examples/openlayers/07_graphiclayer_clover.html

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,21 +140,24 @@
140140
}
141141

142142
map.once('postrender', function () {
143+
var source = new ol.source.Graphic({
144+
graphics: graphics,
145+
render: "canvas",
146+
map: map,
147+
isHighLight: true
148+
});
149+
source.on('graphichighlighted', function (e) {
150+
if (e.value.graphic) {
151+
var coords = e.value.graphic.getGeometry().getCoordinates();
152+
content.innerHTML = resources.text_coordinate + ":[" + coords[0] + "," +
153+
coords[1] + "]";
154+
overlay.setPosition(coords);
155+
return;
156+
}
157+
overlay.setPosition(undefined);
158+
});
143159
var graphicLayer = new ol.layer.Image({
144-
source: new ol.source.Graphic({
145-
graphics: graphics,
146-
render:"canvas",
147-
map: map,
148-
onClick: function (graphic) {
149-
if (graphic) {
150-
var coords = graphic.getGeometry().getCoordinates();
151-
content.innerHTML = resources.text_coordinate + ":[" + coords[0] + "," + coords[1] + "]";
152-
overlay.setPosition(graphic.getGeometry().getCoordinates());
153-
return;
154-
}
155-
overlay.setPosition(undefined);
156-
}
157-
})
160+
source: source
158161
});
159162
map.addLayer(graphicLayer);
160163
})

examples/openlayers/07_graphiclayer_image.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494
img.onload = function () {
9595
var imageStyle = new ol.style.Icon(({
9696
img: this,
97-
size: [20, 20],
98-
imgSize: [20, 20]
97+
size: [32, 32],
98+
imgSize: [32, 32]
9999
}));
100100
var features = Papa.parse(nycData, {skipEmptyLines: true, header: true}).data;
101101
var counts = features.length; //矢量点的个数

src/common/util/FetchRequest.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,6 @@ SuperMap.Util.RequestJSONPPromise = {
301301
if (keysCount == 0) {
302302
return false;
303303
}
304-
if (splitQuestUrl == null) {
305-
splitQuestUrl = new Array();
306-
}
307304
splitQuestUrl.push(sectionURL);
308305
sectionURL = url;
309306
keysCount = 0;
@@ -331,9 +328,6 @@ SuperMap.Util.RequestJSONPPromise = {
331328
sectionURL += me.queryKeys[i] + "=" + tempLeftValue;
332329
leftValue = leftValue.substring(leftLength);
333330
if (tempLeftValue.length > 0) {
334-
if (splitQuestUrl == null) {
335-
splitQuestUrl = new Array();
336-
}
337331
splitQuestUrl.push(sectionURL);
338332
sectionURL = url;
339333
keysCount = 0;
@@ -350,9 +344,6 @@ SuperMap.Util.RequestJSONPPromise = {
350344
}
351345
}
352346
}
353-
if (splitQuestUrl == null) {
354-
splitQuestUrl = new Array();
355-
}
356347
splitQuestUrl.push(sectionURL);
357348
me.send(splitQuestUrl, "SuperMap.Util.RequestJSONPPromise.supermap_callbacks[" + uid + "]", config && config.proxy);
358349
return p;

src/leaflet/overlay/dataflow/MapvRenderer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,10 @@ export var MapvRenderer = MapVLayer.extend({
114114
};
115115
mapvOps.strokeStyle = options.color;
116116
mapvOps.lineWidth = options.width;
117-
mapvOps.globalAlpha = options.opacity;
117+
mapvOps.globalAlpha = options.fillOpacity || options.opacity;
118118
mapvOps.lineCap = options.lineCap;
119119
mapvOps.lineJoin = options.lineJoin;
120120
mapvOps.fillStyle = options.fillColor;
121-
mapvOps.globalAlpha = options.fillOpacity;
122121
mapvOps.size = options.radius;
123122
return mapvOps;
124123
}

src/openlayers/overlay/vectortile/olExtends.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,17 @@ export var olExtends = function (targetMap) {
7575
geometryType === ol.geom.GeometryType.MULTI_LINE_STRING ? new ol.geom.MultiLineString(null) :
7676
null;
7777
}
78-
geom.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates, ends);
79-
feature = new this.featureClass_();
80-
if (this.geometryName_) {
81-
feature.setGeometryName(this.geometryName_);
78+
if (geom) {
79+
geom.setFlatCoordinates(ol.geom.GeometryLayout.XY, flatCoordinates, ends);
80+
feature = new this.featureClass_();
81+
if (this.geometryName_) {
82+
feature.setGeometryName(this.geometryName_);
83+
}
84+
var geometry = ol.format.Feature.transformWithOptions(geom, false, this.adaptOptions(opt_options));
85+
feature.setGeometry(geometry);
86+
feature.setId(id);
87+
feature.setProperties(values);
8288
}
83-
var geometry = ol.format.Feature.transformWithOptions(geom, false, this.adaptOptions(opt_options));
84-
feature.setGeometry(geometry);
85-
feature.setId(id);
86-
feature.setProperties(values);
8789
}
8890

8991
return feature;

0 commit comments

Comments
 (0)