@mint-ui/map 0.1.8-beta → 0.2.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/mint-map/MintMap.d.ts +3 -1
- package/dist/components/mint-map/MintMap.js +19 -3
- package/dist/components/mint-map/core/util/calculate.d.ts +5 -0
- package/dist/components/mint-map/core/util/calculate.js +68 -8
- package/dist/components/mint-map/core/wrapper/MapMarkerWrapper.js +2 -2
- package/dist/components/mint-map/google/GoogleMintMapController.js +2 -6
- package/dist/components/mint-map/naver/NaverMintMapController.js +3 -3
- package/dist/index.es.js +94 -22
- package/dist/index.umd.js +94 -22
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ export interface MintMapProps extends MintMapEvents {
|
|
|
11
11
|
base?: BaseProps;
|
|
12
12
|
visible?: boolean;
|
|
13
13
|
markerCache?: boolean;
|
|
14
|
+
markerCachePoolSize?: number;
|
|
14
15
|
}
|
|
15
16
|
export interface MintMapEvents {
|
|
16
17
|
onBoundsChanged?: (bounds: Bounds) => void;
|
|
@@ -35,7 +36,8 @@ export declare class Bounds {
|
|
|
35
36
|
private covertNWSEtoNESW;
|
|
36
37
|
private covertNESWtoNWSE;
|
|
37
38
|
getCenter(): Position;
|
|
38
|
-
|
|
39
|
+
getIncludedPositions(positions: Position[]): Position[];
|
|
40
|
+
includes(positions: Position | Position[]): boolean;
|
|
39
41
|
includesOnlyOnePoint(positions: Position[]): boolean;
|
|
40
42
|
intersects(positions: Position[]): boolean;
|
|
41
43
|
}
|
|
@@ -68,10 +68,26 @@ var Bounds = function () {
|
|
|
68
68
|
return new Position(this.nw.lat + (this.se.lat - this.nw.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
Bounds.prototype.
|
|
71
|
+
Bounds.prototype.getIncludedPositions = function (positions) {
|
|
72
|
+
var result = [];
|
|
73
|
+
|
|
72
74
|
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
73
75
|
var pos = positions_1[_i];
|
|
74
76
|
|
|
77
|
+
if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
|
|
78
|
+
result.push(pos);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return result;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
Bounds.prototype.includes = function (positions) {
|
|
86
|
+
positions = Array.isArray(positions) ? positions : [positions];
|
|
87
|
+
|
|
88
|
+
for (var _i = 0, positions_2 = positions; _i < positions_2.length; _i++) {
|
|
89
|
+
var pos = positions_2[_i];
|
|
90
|
+
|
|
75
91
|
if (this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng) {
|
|
76
92
|
return false;
|
|
77
93
|
}
|
|
@@ -81,8 +97,8 @@ var Bounds = function () {
|
|
|
81
97
|
};
|
|
82
98
|
|
|
83
99
|
Bounds.prototype.includesOnlyOnePoint = function (positions) {
|
|
84
|
-
for (var _i = 0,
|
|
85
|
-
var pos =
|
|
100
|
+
for (var _i = 0, positions_3 = positions; _i < positions_3.length; _i++) {
|
|
101
|
+
var pos = positions_3[_i];
|
|
86
102
|
|
|
87
103
|
if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
|
|
88
104
|
return true;
|
|
@@ -2,7 +2,12 @@ import { Position } from "../../MintMap";
|
|
|
2
2
|
export declare class PolygonCalculator {
|
|
3
3
|
static getCenter(positions: Position[]): Position;
|
|
4
4
|
static intersects(positions1: Position[], positions2: Position[]): boolean;
|
|
5
|
+
static getIncludedPositions(polygon: Position[], position: Position | Position[]): Position[];
|
|
6
|
+
private static convertPolygonToLinePoints;
|
|
5
7
|
private static convertPositionToPoints;
|
|
8
|
+
private static getCrossPoint;
|
|
9
|
+
private static toFixedPosition;
|
|
10
|
+
private static getCrossPointAll;
|
|
6
11
|
private static findCrossPoint;
|
|
7
12
|
}
|
|
8
13
|
export interface NextPositionContext {
|
|
@@ -66,22 +66,82 @@ var PolygonCalculator = function () {
|
|
|
66
66
|
return false;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
+
PolygonCalculator.getIncludedPositions = function (polygon, position) {
|
|
70
|
+
var targets = Array.isArray(position) ? position : [position];
|
|
71
|
+
var result = [];
|
|
72
|
+
var maxX = Math.max.apply(Math, polygon.map(function (pos) {
|
|
73
|
+
return pos.lng;
|
|
74
|
+
})) + 1;
|
|
75
|
+
var lines = this.convertPolygonToLinePoints(polygon);
|
|
76
|
+
|
|
77
|
+
for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) {
|
|
78
|
+
var target = targets_1[_i];
|
|
79
|
+
var tempLine = this.convertPositionToPoints(target, new MintMap.Position(target.lat, maxX));
|
|
80
|
+
var crossPoints = this.getCrossPointAll(lines, tempLine);
|
|
81
|
+
|
|
82
|
+
if (crossPoints.length > 0 && crossPoints.length % 2 != 0) {
|
|
83
|
+
result.push(target);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return result;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
PolygonCalculator.convertPolygonToLinePoints = function (polygon) {
|
|
91
|
+
var lines = [];
|
|
92
|
+
|
|
93
|
+
for (var i = 0; i < polygon.length; i++) {
|
|
94
|
+
lines.push(this.convertPositionToPoints(polygon[i], polygon[i + 1 === polygon.length ? 0 : i + 1]));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return lines;
|
|
98
|
+
};
|
|
99
|
+
|
|
69
100
|
PolygonCalculator.convertPositionToPoints = function (pos1, pos2) {
|
|
70
101
|
return new LinePoints(pos1.lng, pos1.lat, pos2.lng, pos2.lat);
|
|
71
102
|
};
|
|
72
103
|
|
|
73
|
-
PolygonCalculator.
|
|
104
|
+
PolygonCalculator.getCrossPoint = function (sr, tr) {
|
|
105
|
+
var p1 = (sr.x1 - sr.x2) * (tr.y1 - tr.y2) - (sr.y1 - sr.y2) * (tr.x1 - tr.x2);
|
|
106
|
+
|
|
107
|
+
if (p1 != 0) {
|
|
108
|
+
var x = ((sr.x1 * sr.y2 - sr.y1 * sr.x2) * (tr.x1 - tr.x2) - (sr.x1 - sr.x2) * (tr.x1 * tr.y2 - tr.y1 * tr.x2)) / p1;
|
|
109
|
+
var y = ((sr.x1 * sr.y2 - sr.y1 * sr.x2) * (tr.y1 - tr.y2) - (sr.y1 - sr.y2) * (tr.x1 * tr.y2 - tr.y1 * tr.x2)) / p1;
|
|
110
|
+
|
|
111
|
+
if (this.toFixedPosition((x - sr.x1) * (x - sr.x2)) <= 0 && this.toFixedPosition((y - sr.y1) * (y - sr.y2)) <= 0 && this.toFixedPosition((x - tr.x1) * (x - tr.x2)) <= 0 && this.toFixedPosition((y - tr.y1) * (y - tr.y2)) <= 0) {
|
|
112
|
+
return {
|
|
113
|
+
x: x,
|
|
114
|
+
y: y
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
PolygonCalculator.toFixedPosition = function (n) {
|
|
121
|
+
return Number(n.toFixed(15));
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
PolygonCalculator.getCrossPointAll = function (sr, tr) {
|
|
125
|
+
var result = [];
|
|
126
|
+
|
|
74
127
|
for (var _i = 0, sr_1 = sr; _i < sr_1.length; _i++) {
|
|
75
128
|
var tmp = sr_1[_i];
|
|
76
|
-
var
|
|
129
|
+
var p = this.getCrossPoint(tmp, tr);
|
|
77
130
|
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
131
|
+
if (p) {
|
|
132
|
+
result.push(p);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return result;
|
|
137
|
+
};
|
|
81
138
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
139
|
+
PolygonCalculator.findCrossPoint = function (sr, tr) {
|
|
140
|
+
for (var _i = 0, sr_2 = sr; _i < sr_2.length; _i++) {
|
|
141
|
+
var tmp = sr_2[_i];
|
|
142
|
+
|
|
143
|
+
if (this.getCrossPoint(tmp, tr)) {
|
|
144
|
+
return true;
|
|
85
145
|
}
|
|
86
146
|
}
|
|
87
147
|
|
|
@@ -100,7 +100,7 @@ function MapMarkerWrapper(_a) {
|
|
|
100
100
|
divCloneRef.current && divCloneRef.current.removeEventListener('animationend', aniListener_1);
|
|
101
101
|
|
|
102
102
|
if (markerRef.current) {
|
|
103
|
-
|
|
103
|
+
controller.clearDrawable(markerRef.current);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
divCloneRef.current = undefined;
|
|
@@ -113,7 +113,7 @@ function MapMarkerWrapper(_a) {
|
|
|
113
113
|
divElement.removeEventListener('mouseover', onMouseOverHandler);
|
|
114
114
|
|
|
115
115
|
if (markerRef.current) {
|
|
116
|
-
|
|
116
|
+
controller.clearDrawable(markerRef.current);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
};
|
|
@@ -361,7 +361,7 @@ var GoogleMintMapController = function (_super) {
|
|
|
361
361
|
|
|
362
362
|
case 2:
|
|
363
363
|
map = new google.maps.Map(divElement, {
|
|
364
|
-
mapId: this.mapProps.mapId,
|
|
364
|
+
mapId: this.mapProps.mapId || 'TEMP_MAP_ID',
|
|
365
365
|
center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
|
|
366
366
|
maxZoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.maxZoomLevel,
|
|
367
367
|
minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
|
|
@@ -369,17 +369,13 @@ var GoogleMintMapController = function (_super) {
|
|
|
369
369
|
disableDefaultUI: true,
|
|
370
370
|
gestureHandling: 'greedy'
|
|
371
371
|
});
|
|
372
|
-
map.addListener('
|
|
373
|
-
console.log('map dragend');
|
|
372
|
+
map.addListener('idle', function () {
|
|
374
373
|
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
375
374
|
});
|
|
376
375
|
map.addListener('zoom_changed', function () {
|
|
377
|
-
console.log('zoom_changed');
|
|
378
376
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
379
|
-
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
380
377
|
});
|
|
381
378
|
map.addListener('click', function (e) {
|
|
382
|
-
console.log('map click', e);
|
|
383
379
|
var pos = new MintMap.Position(e.latLng.lat(), e.latLng.lng());
|
|
384
380
|
pos.offset = new MintMap.Offset(e.pixel.x, e.pixel.y);
|
|
385
381
|
_this.mapProps.onClick && _this.mapProps.onClick(pos);
|
|
@@ -38,7 +38,7 @@ var NaverMintMapController = function (_super) {
|
|
|
38
38
|
});
|
|
39
39
|
}).setClear(function (item) {
|
|
40
40
|
item.setMap(null);
|
|
41
|
-
}).createPool(1000).setCheckLiveTimeInterval(1000);
|
|
41
|
+
}).createPool(this.mapProps.markerCachePoolSize && this.mapProps.markerCachePoolSize > 0 ? this.mapProps.markerCachePoolSize : 1000).setCheckLiveTimeInterval(1000);
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
NaverMintMapController.prototype.createPolyline = function (polyline) {
|
|
@@ -414,12 +414,12 @@ var NaverMintMapController = function (_super) {
|
|
|
414
414
|
} else {
|
|
415
415
|
_this.dragged = true;
|
|
416
416
|
}
|
|
417
|
-
|
|
417
|
+
});
|
|
418
|
+
map.addListener('idle', function () {
|
|
418
419
|
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
419
420
|
});
|
|
420
421
|
map.addListener('zoom_changed', function () {
|
|
421
422
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
422
|
-
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
423
423
|
});
|
|
424
424
|
map.addListener('click', function (e) {
|
|
425
425
|
console.log('map click', e);
|
package/dist/index.es.js
CHANGED
|
@@ -158,22 +158,82 @@ var PolygonCalculator = function () {
|
|
|
158
158
|
return false;
|
|
159
159
|
};
|
|
160
160
|
|
|
161
|
+
PolygonCalculator.getIncludedPositions = function (polygon, position) {
|
|
162
|
+
var targets = Array.isArray(position) ? position : [position];
|
|
163
|
+
var result = [];
|
|
164
|
+
var maxX = Math.max.apply(Math, polygon.map(function (pos) {
|
|
165
|
+
return pos.lng;
|
|
166
|
+
})) + 1;
|
|
167
|
+
var lines = this.convertPolygonToLinePoints(polygon);
|
|
168
|
+
|
|
169
|
+
for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) {
|
|
170
|
+
var target = targets_1[_i];
|
|
171
|
+
var tempLine = this.convertPositionToPoints(target, new Position(target.lat, maxX));
|
|
172
|
+
var crossPoints = this.getCrossPointAll(lines, tempLine);
|
|
173
|
+
|
|
174
|
+
if (crossPoints.length > 0 && crossPoints.length % 2 != 0) {
|
|
175
|
+
result.push(target);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return result;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
PolygonCalculator.convertPolygonToLinePoints = function (polygon) {
|
|
183
|
+
var lines = [];
|
|
184
|
+
|
|
185
|
+
for (var i = 0; i < polygon.length; i++) {
|
|
186
|
+
lines.push(this.convertPositionToPoints(polygon[i], polygon[i + 1 === polygon.length ? 0 : i + 1]));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return lines;
|
|
190
|
+
};
|
|
191
|
+
|
|
161
192
|
PolygonCalculator.convertPositionToPoints = function (pos1, pos2) {
|
|
162
193
|
return new LinePoints(pos1.lng, pos1.lat, pos2.lng, pos2.lat);
|
|
163
194
|
};
|
|
164
195
|
|
|
165
|
-
PolygonCalculator.
|
|
196
|
+
PolygonCalculator.getCrossPoint = function (sr, tr) {
|
|
197
|
+
var p1 = (sr.x1 - sr.x2) * (tr.y1 - tr.y2) - (sr.y1 - sr.y2) * (tr.x1 - tr.x2);
|
|
198
|
+
|
|
199
|
+
if (p1 != 0) {
|
|
200
|
+
var x = ((sr.x1 * sr.y2 - sr.y1 * sr.x2) * (tr.x1 - tr.x2) - (sr.x1 - sr.x2) * (tr.x1 * tr.y2 - tr.y1 * tr.x2)) / p1;
|
|
201
|
+
var y = ((sr.x1 * sr.y2 - sr.y1 * sr.x2) * (tr.y1 - tr.y2) - (sr.y1 - sr.y2) * (tr.x1 * tr.y2 - tr.y1 * tr.x2)) / p1;
|
|
202
|
+
|
|
203
|
+
if (this.toFixedPosition((x - sr.x1) * (x - sr.x2)) <= 0 && this.toFixedPosition((y - sr.y1) * (y - sr.y2)) <= 0 && this.toFixedPosition((x - tr.x1) * (x - tr.x2)) <= 0 && this.toFixedPosition((y - tr.y1) * (y - tr.y2)) <= 0) {
|
|
204
|
+
return {
|
|
205
|
+
x: x,
|
|
206
|
+
y: y
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
PolygonCalculator.toFixedPosition = function (n) {
|
|
213
|
+
return Number(n.toFixed(15));
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
PolygonCalculator.getCrossPointAll = function (sr, tr) {
|
|
217
|
+
var result = [];
|
|
218
|
+
|
|
166
219
|
for (var _i = 0, sr_1 = sr; _i < sr_1.length; _i++) {
|
|
167
220
|
var tmp = sr_1[_i];
|
|
168
|
-
var
|
|
221
|
+
var p = this.getCrossPoint(tmp, tr);
|
|
169
222
|
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
|
|
223
|
+
if (p) {
|
|
224
|
+
result.push(p);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
173
227
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
228
|
+
return result;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
PolygonCalculator.findCrossPoint = function (sr, tr) {
|
|
232
|
+
for (var _i = 0, sr_2 = sr; _i < sr_2.length; _i++) {
|
|
233
|
+
var tmp = sr_2[_i];
|
|
234
|
+
|
|
235
|
+
if (this.getCrossPoint(tmp, tr)) {
|
|
236
|
+
return true;
|
|
177
237
|
}
|
|
178
238
|
}
|
|
179
239
|
|
|
@@ -362,7 +422,7 @@ var NaverMintMapController = function (_super) {
|
|
|
362
422
|
});
|
|
363
423
|
}).setClear(function (item) {
|
|
364
424
|
item.setMap(null);
|
|
365
|
-
}).createPool(1000).setCheckLiveTimeInterval(1000);
|
|
425
|
+
}).createPool(this.mapProps.markerCachePoolSize && this.mapProps.markerCachePoolSize > 0 ? this.mapProps.markerCachePoolSize : 1000).setCheckLiveTimeInterval(1000);
|
|
366
426
|
};
|
|
367
427
|
|
|
368
428
|
NaverMintMapController.prototype.createPolyline = function (polyline) {
|
|
@@ -738,12 +798,12 @@ var NaverMintMapController = function (_super) {
|
|
|
738
798
|
} else {
|
|
739
799
|
_this.dragged = true;
|
|
740
800
|
}
|
|
741
|
-
|
|
801
|
+
});
|
|
802
|
+
map.addListener('idle', function () {
|
|
742
803
|
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
743
804
|
});
|
|
744
805
|
map.addListener('zoom_changed', function () {
|
|
745
806
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
746
|
-
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
747
807
|
});
|
|
748
808
|
map.addListener('click', function (e) {
|
|
749
809
|
console.log('map click', e);
|
|
@@ -1174,7 +1234,7 @@ var GoogleMintMapController = function (_super) {
|
|
|
1174
1234
|
|
|
1175
1235
|
case 2:
|
|
1176
1236
|
map = new google.maps.Map(divElement, {
|
|
1177
|
-
mapId: this.mapProps.mapId,
|
|
1237
|
+
mapId: this.mapProps.mapId || 'TEMP_MAP_ID',
|
|
1178
1238
|
center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
|
|
1179
1239
|
maxZoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.maxZoomLevel,
|
|
1180
1240
|
minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
|
|
@@ -1182,17 +1242,13 @@ var GoogleMintMapController = function (_super) {
|
|
|
1182
1242
|
disableDefaultUI: true,
|
|
1183
1243
|
gestureHandling: 'greedy'
|
|
1184
1244
|
});
|
|
1185
|
-
map.addListener('
|
|
1186
|
-
console.log('map dragend');
|
|
1245
|
+
map.addListener('idle', function () {
|
|
1187
1246
|
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
1188
1247
|
});
|
|
1189
1248
|
map.addListener('zoom_changed', function () {
|
|
1190
|
-
console.log('zoom_changed');
|
|
1191
1249
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
1192
|
-
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
1193
1250
|
});
|
|
1194
1251
|
map.addListener('click', function (e) {
|
|
1195
|
-
console.log('map click', e);
|
|
1196
1252
|
var pos = new Position(e.latLng.lat(), e.latLng.lng());
|
|
1197
1253
|
pos.offset = new Offset(e.pixel.x, e.pixel.y);
|
|
1198
1254
|
_this.mapProps.onClick && _this.mapProps.onClick(pos);
|
|
@@ -1300,10 +1356,26 @@ var Bounds = function () {
|
|
|
1300
1356
|
return new Position(this.nw.lat + (this.se.lat - this.nw.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
|
|
1301
1357
|
};
|
|
1302
1358
|
|
|
1303
|
-
Bounds.prototype.
|
|
1359
|
+
Bounds.prototype.getIncludedPositions = function (positions) {
|
|
1360
|
+
var result = [];
|
|
1361
|
+
|
|
1304
1362
|
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
1305
1363
|
var pos = positions_1[_i];
|
|
1306
1364
|
|
|
1365
|
+
if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
|
|
1366
|
+
result.push(pos);
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
return result;
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1373
|
+
Bounds.prototype.includes = function (positions) {
|
|
1374
|
+
positions = Array.isArray(positions) ? positions : [positions];
|
|
1375
|
+
|
|
1376
|
+
for (var _i = 0, positions_2 = positions; _i < positions_2.length; _i++) {
|
|
1377
|
+
var pos = positions_2[_i];
|
|
1378
|
+
|
|
1307
1379
|
if (this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng) {
|
|
1308
1380
|
return false;
|
|
1309
1381
|
}
|
|
@@ -1313,8 +1385,8 @@ var Bounds = function () {
|
|
|
1313
1385
|
};
|
|
1314
1386
|
|
|
1315
1387
|
Bounds.prototype.includesOnlyOnePoint = function (positions) {
|
|
1316
|
-
for (var _i = 0,
|
|
1317
|
-
var pos =
|
|
1388
|
+
for (var _i = 0, positions_3 = positions; _i < positions_3.length; _i++) {
|
|
1389
|
+
var pos = positions_3[_i];
|
|
1318
1390
|
|
|
1319
1391
|
if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
|
|
1320
1392
|
return true;
|
|
@@ -1784,7 +1856,7 @@ function MapMarkerWrapper(_a) {
|
|
|
1784
1856
|
divCloneRef.current && divCloneRef.current.removeEventListener('animationend', aniListener_1);
|
|
1785
1857
|
|
|
1786
1858
|
if (markerRef.current) {
|
|
1787
|
-
|
|
1859
|
+
controller.clearDrawable(markerRef.current);
|
|
1788
1860
|
}
|
|
1789
1861
|
|
|
1790
1862
|
divCloneRef.current = undefined;
|
|
@@ -1797,7 +1869,7 @@ function MapMarkerWrapper(_a) {
|
|
|
1797
1869
|
divElement.removeEventListener('mouseover', onMouseOverHandler);
|
|
1798
1870
|
|
|
1799
1871
|
if (markerRef.current) {
|
|
1800
|
-
|
|
1872
|
+
controller.clearDrawable(markerRef.current);
|
|
1801
1873
|
}
|
|
1802
1874
|
}
|
|
1803
1875
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -163,22 +163,82 @@
|
|
|
163
163
|
return false;
|
|
164
164
|
};
|
|
165
165
|
|
|
166
|
+
PolygonCalculator.getIncludedPositions = function (polygon, position) {
|
|
167
|
+
var targets = Array.isArray(position) ? position : [position];
|
|
168
|
+
var result = [];
|
|
169
|
+
var maxX = Math.max.apply(Math, polygon.map(function (pos) {
|
|
170
|
+
return pos.lng;
|
|
171
|
+
})) + 1;
|
|
172
|
+
var lines = this.convertPolygonToLinePoints(polygon);
|
|
173
|
+
|
|
174
|
+
for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) {
|
|
175
|
+
var target = targets_1[_i];
|
|
176
|
+
var tempLine = this.convertPositionToPoints(target, new Position(target.lat, maxX));
|
|
177
|
+
var crossPoints = this.getCrossPointAll(lines, tempLine);
|
|
178
|
+
|
|
179
|
+
if (crossPoints.length > 0 && crossPoints.length % 2 != 0) {
|
|
180
|
+
result.push(target);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return result;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
PolygonCalculator.convertPolygonToLinePoints = function (polygon) {
|
|
188
|
+
var lines = [];
|
|
189
|
+
|
|
190
|
+
for (var i = 0; i < polygon.length; i++) {
|
|
191
|
+
lines.push(this.convertPositionToPoints(polygon[i], polygon[i + 1 === polygon.length ? 0 : i + 1]));
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return lines;
|
|
195
|
+
};
|
|
196
|
+
|
|
166
197
|
PolygonCalculator.convertPositionToPoints = function (pos1, pos2) {
|
|
167
198
|
return new LinePoints(pos1.lng, pos1.lat, pos2.lng, pos2.lat);
|
|
168
199
|
};
|
|
169
200
|
|
|
170
|
-
PolygonCalculator.
|
|
201
|
+
PolygonCalculator.getCrossPoint = function (sr, tr) {
|
|
202
|
+
var p1 = (sr.x1 - sr.x2) * (tr.y1 - tr.y2) - (sr.y1 - sr.y2) * (tr.x1 - tr.x2);
|
|
203
|
+
|
|
204
|
+
if (p1 != 0) {
|
|
205
|
+
var x = ((sr.x1 * sr.y2 - sr.y1 * sr.x2) * (tr.x1 - tr.x2) - (sr.x1 - sr.x2) * (tr.x1 * tr.y2 - tr.y1 * tr.x2)) / p1;
|
|
206
|
+
var y = ((sr.x1 * sr.y2 - sr.y1 * sr.x2) * (tr.y1 - tr.y2) - (sr.y1 - sr.y2) * (tr.x1 * tr.y2 - tr.y1 * tr.x2)) / p1;
|
|
207
|
+
|
|
208
|
+
if (this.toFixedPosition((x - sr.x1) * (x - sr.x2)) <= 0 && this.toFixedPosition((y - sr.y1) * (y - sr.y2)) <= 0 && this.toFixedPosition((x - tr.x1) * (x - tr.x2)) <= 0 && this.toFixedPosition((y - tr.y1) * (y - tr.y2)) <= 0) {
|
|
209
|
+
return {
|
|
210
|
+
x: x,
|
|
211
|
+
y: y
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
PolygonCalculator.toFixedPosition = function (n) {
|
|
218
|
+
return Number(n.toFixed(15));
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
PolygonCalculator.getCrossPointAll = function (sr, tr) {
|
|
222
|
+
var result = [];
|
|
223
|
+
|
|
171
224
|
for (var _i = 0, sr_1 = sr; _i < sr_1.length; _i++) {
|
|
172
225
|
var tmp = sr_1[_i];
|
|
173
|
-
var
|
|
226
|
+
var p = this.getCrossPoint(tmp, tr);
|
|
174
227
|
|
|
175
|
-
if (
|
|
176
|
-
|
|
177
|
-
|
|
228
|
+
if (p) {
|
|
229
|
+
result.push(p);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
178
232
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
233
|
+
return result;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
PolygonCalculator.findCrossPoint = function (sr, tr) {
|
|
237
|
+
for (var _i = 0, sr_2 = sr; _i < sr_2.length; _i++) {
|
|
238
|
+
var tmp = sr_2[_i];
|
|
239
|
+
|
|
240
|
+
if (this.getCrossPoint(tmp, tr)) {
|
|
241
|
+
return true;
|
|
182
242
|
}
|
|
183
243
|
}
|
|
184
244
|
|
|
@@ -367,7 +427,7 @@
|
|
|
367
427
|
});
|
|
368
428
|
}).setClear(function (item) {
|
|
369
429
|
item.setMap(null);
|
|
370
|
-
}).createPool(1000).setCheckLiveTimeInterval(1000);
|
|
430
|
+
}).createPool(this.mapProps.markerCachePoolSize && this.mapProps.markerCachePoolSize > 0 ? this.mapProps.markerCachePoolSize : 1000).setCheckLiveTimeInterval(1000);
|
|
371
431
|
};
|
|
372
432
|
|
|
373
433
|
NaverMintMapController.prototype.createPolyline = function (polyline) {
|
|
@@ -743,12 +803,12 @@
|
|
|
743
803
|
} else {
|
|
744
804
|
_this.dragged = true;
|
|
745
805
|
}
|
|
746
|
-
|
|
806
|
+
});
|
|
807
|
+
map.addListener('idle', function () {
|
|
747
808
|
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
748
809
|
});
|
|
749
810
|
map.addListener('zoom_changed', function () {
|
|
750
811
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
751
|
-
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
752
812
|
});
|
|
753
813
|
map.addListener('click', function (e) {
|
|
754
814
|
console.log('map click', e);
|
|
@@ -1179,7 +1239,7 @@
|
|
|
1179
1239
|
|
|
1180
1240
|
case 2:
|
|
1181
1241
|
map = new google.maps.Map(divElement, {
|
|
1182
|
-
mapId: this.mapProps.mapId,
|
|
1242
|
+
mapId: this.mapProps.mapId || 'TEMP_MAP_ID',
|
|
1183
1243
|
center: (_a = this.mapProps.base) === null || _a === void 0 ? void 0 : _a.center,
|
|
1184
1244
|
maxZoom: (_b = this.mapProps.base) === null || _b === void 0 ? void 0 : _b.maxZoomLevel,
|
|
1185
1245
|
minZoom: (_c = this.mapProps.base) === null || _c === void 0 ? void 0 : _c.minZoomLevel,
|
|
@@ -1187,17 +1247,13 @@
|
|
|
1187
1247
|
disableDefaultUI: true,
|
|
1188
1248
|
gestureHandling: 'greedy'
|
|
1189
1249
|
});
|
|
1190
|
-
map.addListener('
|
|
1191
|
-
console.log('map dragend');
|
|
1250
|
+
map.addListener('idle', function () {
|
|
1192
1251
|
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
1193
1252
|
});
|
|
1194
1253
|
map.addListener('zoom_changed', function () {
|
|
1195
|
-
console.log('zoom_changed');
|
|
1196
1254
|
_this.map && _this.mapProps.onZoomChanged && _this.mapProps.onZoomChanged(_this.map.getZoom());
|
|
1197
|
-
_this.mapProps.onBoundsChanged && _this.mapProps.onBoundsChanged(_this.getCurrBounds());
|
|
1198
1255
|
});
|
|
1199
1256
|
map.addListener('click', function (e) {
|
|
1200
|
-
console.log('map click', e);
|
|
1201
1257
|
var pos = new Position(e.latLng.lat(), e.latLng.lng());
|
|
1202
1258
|
pos.offset = new Offset(e.pixel.x, e.pixel.y);
|
|
1203
1259
|
_this.mapProps.onClick && _this.mapProps.onClick(pos);
|
|
@@ -1305,10 +1361,26 @@
|
|
|
1305
1361
|
return new Position(this.nw.lat + (this.se.lat - this.nw.lat) / 2, this.nw.lng + (this.se.lng - this.nw.lng) / 2);
|
|
1306
1362
|
};
|
|
1307
1363
|
|
|
1308
|
-
Bounds.prototype.
|
|
1364
|
+
Bounds.prototype.getIncludedPositions = function (positions) {
|
|
1365
|
+
var result = [];
|
|
1366
|
+
|
|
1309
1367
|
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
|
|
1310
1368
|
var pos = positions_1[_i];
|
|
1311
1369
|
|
|
1370
|
+
if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
|
|
1371
|
+
result.push(pos);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
return result;
|
|
1376
|
+
};
|
|
1377
|
+
|
|
1378
|
+
Bounds.prototype.includes = function (positions) {
|
|
1379
|
+
positions = Array.isArray(positions) ? positions : [positions];
|
|
1380
|
+
|
|
1381
|
+
for (var _i = 0, positions_2 = positions; _i < positions_2.length; _i++) {
|
|
1382
|
+
var pos = positions_2[_i];
|
|
1383
|
+
|
|
1312
1384
|
if (this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng) {
|
|
1313
1385
|
return false;
|
|
1314
1386
|
}
|
|
@@ -1318,8 +1390,8 @@
|
|
|
1318
1390
|
};
|
|
1319
1391
|
|
|
1320
1392
|
Bounds.prototype.includesOnlyOnePoint = function (positions) {
|
|
1321
|
-
for (var _i = 0,
|
|
1322
|
-
var pos =
|
|
1393
|
+
for (var _i = 0, positions_3 = positions; _i < positions_3.length; _i++) {
|
|
1394
|
+
var pos = positions_3[_i];
|
|
1323
1395
|
|
|
1324
1396
|
if (!(this.nw.lat > pos.lat || this.se.lat < pos.lat || this.nw.lng > pos.lng || this.se.lng < pos.lng)) {
|
|
1325
1397
|
return true;
|
|
@@ -1789,7 +1861,7 @@
|
|
|
1789
1861
|
divCloneRef.current && divCloneRef.current.removeEventListener('animationend', aniListener_1);
|
|
1790
1862
|
|
|
1791
1863
|
if (markerRef.current) {
|
|
1792
|
-
|
|
1864
|
+
controller.clearDrawable(markerRef.current);
|
|
1793
1865
|
}
|
|
1794
1866
|
|
|
1795
1867
|
divCloneRef.current = undefined;
|
|
@@ -1802,7 +1874,7 @@
|
|
|
1802
1874
|
divElement.removeEventListener('mouseover', onMouseOverHandler);
|
|
1803
1875
|
|
|
1804
1876
|
if (markerRef.current) {
|
|
1805
|
-
|
|
1877
|
+
controller.clearDrawable(markerRef.current);
|
|
1806
1878
|
}
|
|
1807
1879
|
}
|
|
1808
1880
|
};
|