MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / olExtends

Function olExtends

src/openlayers/overlay/vectortile/olExtends.js:7–372  ·  view source on GitHub ↗
(targetMap)

Source from the content-addressed store, hash-verified

5 import LineString from 'ol/geom/LineString';
6
7 export var olExtends = function(targetMap) {
8 //解决olms.js插件,在使用ol.js时沿线标注不显示的问题,因为ol.geom.LineString.getFlatMidpoint未非公开方法
9 if (!LineString.prototype.getFlatMidpoint) {
10 LineString.prototype.getFlatMidpoint = function() {
11 return this.getCoordinateAt(0.5);
12 };
13 }
14
15 if (Util.getOlVersion() === '4' && window && window.ol && window.ol.geom.flat) {
16 // for ol4-debug
17 window.targetMapCache = targetMap;
18 let ol = window.ol;
19 //解决 new ol.format.MVT({featureClass: ol.Feature})时,非3857显示异常的问题。ol即将发布的5.0版本已解决。
20 // eslint-disable-next-line no-unused-vars
21 ol.format.MVT.prototype.readProjection = function(source) {
22 return new ol.proj.Projection({
23 code: '',
24 units: ol.proj.Units.TILE_PIXELS
25 });
26 };
27 //解决面填充时不能整版填充的问题。ol即将发布的5.0版本已解决。
28 // eslint-disable-next-line no-unused-vars
29 ol.render.canvas.Replay.prototype.applyFill = function(state, geometry) {
30 var fillStyle = state.fillStyle;
31 var fillInstruction = [ol.render.canvas.Instruction.SET_FILL_STYLE, fillStyle];
32 if (typeof fillStyle !== 'string') {
33 var viewExtent = window.targetMapCache
34 .getView()
35 .getProjection()
36 .getExtent();
37 fillInstruction.push([viewExtent[0], viewExtent[3]]);
38 }
39 this.instructions.push(fillInstruction);
40 };
41 //解决面填充时不能整版填充的问题。ol即将发布的5.0版本已解决。
42 // eslint-disable-next-line no-unused-vars
43 ol.render.canvas.Replay.prototype.applyFill = function(state, geometry) {
44 var fillStyle = state.fillStyle;
45 var fillInstruction = [ol.render.canvas.Instruction.SET_FILL_STYLE, fillStyle];
46 if (typeof fillStyle !== 'string') {
47 var viewExtent = window.targetMapCache
48 .getView()
49 .getProjection()
50 .getExtent();
51 fillInstruction.push([viewExtent[0], viewExtent[3]]);
52 }
53 this.instructions.push(fillInstruction);
54 };
55 //解决在多面时,第一个面是逆时针时无法显示的问题。该问题由组件修复。
56 ol.format.MVT.prototype.createFeature_ = function(pbf, rawFeature, opt_options) {
57 var type = rawFeature.type;
58 if (type === 0) {
59 return null;
60 }
61
62 var feature;
63 var id = rawFeature.id;
64 var values = rawFeature.properties;

Callers 2

olExtendSpec.jsFile · 0.90
constructorMethod · 0.90

Calls 15

getViewMethod · 0.80
pushMethod · 0.80
lerpMethod · 0.80
roundMethod · 0.80
saveMethod · 0.80
restoreMethod · 0.80
getExtentMethod · 0.45
setGeometryMethod · 0.45
setIdMethod · 0.45
getLayerMethod · 0.45
getSourceMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected