mapping-component-package-jp 0.0.2
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/README.md +70 -0
- package/dist/index.d.ts +264 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +54 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +48 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/rollup.config.js +48 -0
- package/src/components/FabControl.tsx +63 -0
- package/src/components/GoogleSearchBar.tsx +182 -0
- package/src/components/Icons.tsx +20 -0
- package/src/components/JPMapComponent.tsx +96 -0
- package/src/components/SpeedDialTool.tsx +97 -0
- package/src/components/index.ts +22 -0
- package/src/hooks/useMapManager.ts +48 -0
- package/src/interfaces/AgnifyMapComponentProps.ts +18 -0
- package/src/interfaces/CustomMapOptions.ts +14 -0
- package/src/interfaces/Data/EnterpriseRegion.ts +12 -0
- package/src/interfaces/Data/Farm.ts +10 -0
- package/src/interfaces/Data/Field.ts +19 -0
- package/src/interfaces/Data/LocationData.ts +9 -0
- package/src/interfaces/Data/MapLocationFeature.ts +8 -0
- package/src/interfaces/Data/NDVI.ts +14 -0
- package/src/interfaces/GoogleMapsOptions.ts +39 -0
- package/src/interfaces/Message.ts +13 -0
- package/src/interfaces/Mode.ts +54 -0
- package/src/interfaces/Properties.ts +16 -0
- package/src/js/fieldEncapsulation/iql.field.js +8 -0
- package/src/js/fieldEncapsulation/iql.fieldupload.js +158 -0
- package/src/js/fieldEncapsulation/iql.fieldvalidator.js +574 -0
- package/src/js/mapEncapsulation/circle.functions.js +30 -0
- package/src/js/mapEncapsulation/field.geolocation.js +19 -0
- package/src/js/mapEncapsulation/map.common.js +96 -0
- package/src/js/mapEncapsulation/mapOverlayManager.d.ts +64 -0
- package/src/js/mapEncapsulation/mapOverlayManager.js +2753 -0
- package/src/js/mapEncapsulation/shapes/circle.full.js +789 -0
- package/src/js/mapEncapsulation/shapes/circle.sector.js +1099 -0
- package/src/js/mapEncapsulation/shapes/circle.segment.js +1109 -0
- package/src/js/mapEncapsulation/shapes/polygon.customedit.js +393 -0
- package/src/js/mapEncapsulation/shapes/polyline.customedit.js +478 -0
- package/src/utils/commonUtils.ts +5 -0
- package/src/utils/iconUtils.js +52 -0
- package/src/utils/mapUtils.ts +88 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
export class IQLPolygonCustomEdit {
|
|
2
|
+
|
|
3
|
+
constructor() {
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
delete(map, currentPolygonCustomEdit) {
|
|
7
|
+
|
|
8
|
+
currentPolygonCustomEdit.getPath().forEach(function (vertex, index) {
|
|
9
|
+
if (vertex.marker) {
|
|
10
|
+
vertex.marker.setMap(null);
|
|
11
|
+
vertex.marker = undefined;
|
|
12
|
+
}
|
|
13
|
+
if (vertex.ghostMarker) {
|
|
14
|
+
vertex.ghostMarker.setMap(null);
|
|
15
|
+
vertex.ghostMarker = undefined;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return currentPolygonCustomEdit;
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
edit(map, polygon, currentPolygonCustomEdit, isMobile) {
|
|
24
|
+
|
|
25
|
+
if(isMobile) {
|
|
26
|
+
var svgpi = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 48 48" width="48" height="48">'
|
|
27
|
+
svgpi += '<path fill="rgba(255,255,255,0.01)" d="M 0, 24 a 24,24 0 1,0 48,0 a 24,24 0 1,0 -48,0" />';
|
|
28
|
+
svgpi += '<path fill="rgba(255,255,255,1)" stroke="#303030" stroke-width="1" d="M24 24 m-4,0 a 4,4,0 0,1 8,0 a 4,4 0 0,1 -8,0z" />';
|
|
29
|
+
svgpi += '</svg>';
|
|
30
|
+
|
|
31
|
+
var pointIcon = {
|
|
32
|
+
url: 'data:image/svg+xml;charset=UTF-8;base64,' + btoa(svgpi),
|
|
33
|
+
anchor: new google.maps.Point(24, 24)
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var svgmpi = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 48 48" width="48" height="48">'
|
|
37
|
+
svgmpi += '<path fill="rgba(255,255,255,0.01)" d="M 0, 24 a 24,24 0 1,0 48,0 a 24,24 0 1,0 -48,0" />';
|
|
38
|
+
svgmpi += '<path fill="rgba(255,255,255,0.4)" stroke="#303030" stroke-width="0.3" stroke-opacity="0.01" d="M24 24 m-4,0 a 4,4,0 0,1 8,0 a 4,4 0 0,1 -8,0z" />';
|
|
39
|
+
svgmpi += '</svg>';
|
|
40
|
+
|
|
41
|
+
var midPointIcon = {
|
|
42
|
+
url: 'data:image/svg+xml;charset=UTF-8;base64,' + btoa(svgmpi),
|
|
43
|
+
anchor: new google.maps.Point(24, 24)
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var svgup = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 52 52" style="enable-background:new 0 0 52 52;" xml:space="preserve">';
|
|
47
|
+
svgup += '<g transform="scale(0.4 0.4)">';
|
|
48
|
+
svgup += '<path style="fill:#f1a81e;" d="M38.853,5.324L38.853,5.324c-7.098-7.098-18.607-7.098-25.706,0h0 C6.751,11.72,6.031,23.763,11.459,31L26,52l14.541-21C45.969,23.763,45.249,11.72,38.853,5.324z"/>';
|
|
49
|
+
svgup += '<g transform="translate(13.2 5.9) scale(0.8 0.8)">';
|
|
50
|
+
svgup += '<path style=" stroke:none;fill-rule:nonzero;fill:rgb(255,255,255);fill-opacity:1;" d="M 15.78125 0.0546875 C 15.710938 0.0859375 14.742188 1.03125 13.625 2.148438 C 11.136719 4.644531 11.257812 4.351562 12.300781 5.386719 C 12.957031 6.050781 13.011719 6.09375 13.25 6.09375 C 13.480469 6.09375 13.542969 6.050781 14.0625 5.53125 L 14.625 4.96875 L 14.625 8.019531 C 14.625 11.261719 14.636719 11.398438 14.925781 11.554688 C 15.09375 11.648438 16.90625 11.648438 17.074219 11.554688 C 17.363281 11.398438 17.375 11.261719 17.375 8.019531 L 17.375 4.96875 L 17.9375 5.53125 C 18.457031 6.050781 18.519531 6.09375 18.75 6.09375 C 18.988281 6.09375 19.042969 6.050781 19.699219 5.386719 C 20.742188 4.351562 20.867188 4.648438 18.34375 2.125 C 16.210938 -0.0078125 16.105469 -0.0859375 15.78125 0.0546875 Z M 15.78125 0.0546875 "/>';
|
|
51
|
+
svgup += '<path style=" stroke:none;fill-rule:nonzero;fill:rgb(255,255,255);fill-opacity:1;" d="M 4.21875 11.617188 C 4.148438 11.648438 3.179688 12.59375 2.0625 13.710938 C 0.0703125 15.710938 0.03125 15.75 0.03125 16 C 0.03125 16.25 0.0703125 16.289062 2.113281 18.324219 C 4.648438 20.867188 4.351562 20.742188 5.386719 19.699219 C 6.050781 19.042969 6.09375 18.988281 6.09375 18.75 C 6.09375 18.519531 6.050781 18.457031 5.53125 17.9375 L 4.96875 17.375 L 8.019531 17.375 C 11.261719 17.375 11.398438 17.363281 11.554688 17.074219 C 11.648438 16.90625 11.648438 15.09375 11.554688 14.925781 C 11.398438 14.636719 11.261719 14.625 8.019531 14.625 L 4.96875 14.625 L 5.53125 14.0625 C 6.050781 13.542969 6.09375 13.480469 6.09375 13.25 C 6.09375 13.011719 6.050781 12.957031 5.40625 12.3125 C 4.699219 11.613281 4.5 11.492188 4.21875 11.617188 Z M 4.21875 11.617188 "/>';
|
|
52
|
+
svgup += '<path style=" stroke:none;fill-rule:nonzero;fill:rgb(255,255,255);fill-opacity:1;" d="M 27.34375 11.617188 C 27.273438 11.648438 26.925781 11.976562 26.5625 12.335938 C 25.949219 12.957031 25.90625 13.011719 25.90625 13.25 C 25.90625 13.480469 25.949219 13.542969 26.46875 14.0625 L 27.03125 14.625 L 23.980469 14.625 C 20.738281 14.625 20.601562 14.636719 20.445312 14.925781 C 20.351562 15.09375 20.351562 16.90625 20.445312 17.074219 C 20.601562 17.363281 20.738281 17.375 23.980469 17.375 L 27.03125 17.375 L 26.46875 17.9375 C 25.949219 18.457031 25.90625 18.519531 25.90625 18.75 C 25.90625 18.988281 25.949219 19.042969 26.613281 19.699219 C 27.648438 20.742188 27.351562 20.867188 29.886719 18.324219 C 31.929688 16.289062 31.96875 16.25 31.96875 16 C 31.96875 15.75 31.929688 15.710938 29.90625 13.6875 C 27.773438 11.554688 27.675781 11.476562 27.34375 11.617188 Z M 27.34375 11.617188 "/>';
|
|
53
|
+
svgup += '<path style=" stroke:none;fill-rule:nonzero;fill:rgb(255,255,255);fill-opacity:1;" d="M 14.917969 20.445312 C 14.636719 20.605469 14.625 20.757812 14.625 23.980469 L 14.625 27.03125 L 14.0625 26.46875 C 13.542969 25.949219 13.480469 25.90625 13.25 25.90625 C 13.011719 25.90625 12.957031 25.949219 12.300781 26.613281 C 11.257812 27.648438 11.132812 27.351562 13.675781 29.886719 C 15.710938 31.929688 15.75 31.96875 16 31.96875 C 16.25 31.96875 16.289062 31.929688 18.324219 29.886719 C 20.867188 27.351562 20.742188 27.648438 19.699219 26.613281 C 19.042969 25.949219 18.988281 25.90625 18.75 25.90625 C 18.519531 25.90625 18.457031 25.949219 17.9375 26.46875 L 17.375 27.03125 L 17.375 23.980469 C 17.375 20.738281 17.363281 20.601562 17.074219 20.445312 C 16.90625 20.355469 15.070312 20.355469 14.917969 20.445312 Z M 14.917969 20.445312 "/>';
|
|
54
|
+
svgup += '</g>';
|
|
55
|
+
svgup += '</g>';
|
|
56
|
+
svgup += '</svg>';
|
|
57
|
+
|
|
58
|
+
var handleIconUp = {
|
|
59
|
+
url: 'data:image/svg+xml;charset=UTF-8;base64,' + btoa(svgup),
|
|
60
|
+
anchor: new google.maps.Point(30, 60)
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var svgdown = '<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 52 52" style="enable-background:new 0 0 52 52;" xml:space="preserve">';
|
|
64
|
+
svgdown += '<g transform="scale(0.4 0.4) rotate(180 26 26)">';
|
|
65
|
+
svgdown += '<path style="fill:#f1a81e;" d="M38.853,5.324L38.853,5.324c-7.098-7.098-18.607-7.098-25.706,0h0 C6.751,11.72,6.031,23.763,11.459,31L26,52l14.541-21C45.969,23.763,45.249,11.72,38.853,5.324z"/>';
|
|
66
|
+
svgdown += '<g transform="translate(13.2 5.9) scale(0.8 0.8)">';
|
|
67
|
+
svgdown += '<path style=" stroke:none;fill-rule:nonzero;fill:rgb(255,255,255);fill-opacity:1;" d="M 15.78125 0.0546875 C 15.710938 0.0859375 14.742188 1.03125 13.625 2.148438 C 11.136719 4.644531 11.257812 4.351562 12.300781 5.386719 C 12.957031 6.050781 13.011719 6.09375 13.25 6.09375 C 13.480469 6.09375 13.542969 6.050781 14.0625 5.53125 L 14.625 4.96875 L 14.625 8.019531 C 14.625 11.261719 14.636719 11.398438 14.925781 11.554688 C 15.09375 11.648438 16.90625 11.648438 17.074219 11.554688 C 17.363281 11.398438 17.375 11.261719 17.375 8.019531 L 17.375 4.96875 L 17.9375 5.53125 C 18.457031 6.050781 18.519531 6.09375 18.75 6.09375 C 18.988281 6.09375 19.042969 6.050781 19.699219 5.386719 C 20.742188 4.351562 20.867188 4.648438 18.34375 2.125 C 16.210938 -0.0078125 16.105469 -0.0859375 15.78125 0.0546875 Z M 15.78125 0.0546875 "/>';
|
|
68
|
+
svgdown += '<path style=" stroke:none;fill-rule:nonzero;fill:rgb(255,255,255);fill-opacity:1;" d="M 4.21875 11.617188 C 4.148438 11.648438 3.179688 12.59375 2.0625 13.710938 C 0.0703125 15.710938 0.03125 15.75 0.03125 16 C 0.03125 16.25 0.0703125 16.289062 2.113281 18.324219 C 4.648438 20.867188 4.351562 20.742188 5.386719 19.699219 C 6.050781 19.042969 6.09375 18.988281 6.09375 18.75 C 6.09375 18.519531 6.050781 18.457031 5.53125 17.9375 L 4.96875 17.375 L 8.019531 17.375 C 11.261719 17.375 11.398438 17.363281 11.554688 17.074219 C 11.648438 16.90625 11.648438 15.09375 11.554688 14.925781 C 11.398438 14.636719 11.261719 14.625 8.019531 14.625 L 4.96875 14.625 L 5.53125 14.0625 C 6.050781 13.542969 6.09375 13.480469 6.09375 13.25 C 6.09375 13.011719 6.050781 12.957031 5.40625 12.3125 C 4.699219 11.613281 4.5 11.492188 4.21875 11.617188 Z M 4.21875 11.617188 "/>';
|
|
69
|
+
svgdown += '<path style=" stroke:none;fill-rule:nonzero;fill:rgb(255,255,255);fill-opacity:1;" d="M 27.34375 11.617188 C 27.273438 11.648438 26.925781 11.976562 26.5625 12.335938 C 25.949219 12.957031 25.90625 13.011719 25.90625 13.25 C 25.90625 13.480469 25.949219 13.542969 26.46875 14.0625 L 27.03125 14.625 L 23.980469 14.625 C 20.738281 14.625 20.601562 14.636719 20.445312 14.925781 C 20.351562 15.09375 20.351562 16.90625 20.445312 17.074219 C 20.601562 17.363281 20.738281 17.375 23.980469 17.375 L 27.03125 17.375 L 26.46875 17.9375 C 25.949219 18.457031 25.90625 18.519531 25.90625 18.75 C 25.90625 18.988281 25.949219 19.042969 26.613281 19.699219 C 27.648438 20.742188 27.351562 20.867188 29.886719 18.324219 C 31.929688 16.289062 31.96875 16.25 31.96875 16 C 31.96875 15.75 31.929688 15.710938 29.90625 13.6875 C 27.773438 11.554688 27.675781 11.476562 27.34375 11.617188 Z M 27.34375 11.617188 "/>';
|
|
70
|
+
svgdown += '<path style=" stroke:none;fill-rule:nonzero;fill:rgb(255,255,255);fill-opacity:1;" d="M 14.917969 20.445312 C 14.636719 20.605469 14.625 20.757812 14.625 23.980469 L 14.625 27.03125 L 14.0625 26.46875 C 13.542969 25.949219 13.480469 25.90625 13.25 25.90625 C 13.011719 25.90625 12.957031 25.949219 12.300781 26.613281 C 11.257812 27.648438 11.132812 27.351562 13.675781 29.886719 C 15.710938 31.929688 15.75 31.96875 16 31.96875 C 16.25 31.96875 16.289062 31.929688 18.324219 29.886719 C 20.867188 27.351562 20.742188 27.648438 19.699219 26.613281 C 19.042969 25.949219 18.988281 25.90625 18.75 25.90625 C 18.519531 25.90625 18.457031 25.949219 17.9375 26.46875 L 17.375 27.03125 L 17.375 23.980469 C 17.375 20.738281 17.363281 20.601562 17.074219 20.445312 C 16.90625 20.355469 15.070312 20.355469 14.917969 20.445312 Z M 14.917969 20.445312 "/>';
|
|
71
|
+
svgdown += '</g>';
|
|
72
|
+
svgdown += '</g>';
|
|
73
|
+
svgdown += '</svg>';
|
|
74
|
+
|
|
75
|
+
var handleIconDown = {
|
|
76
|
+
url: 'data:image/svg+xml;charset=UTF-8;base64,' + btoa(svgdown),
|
|
77
|
+
anchor: new google.maps.Point(30, 0)
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} else {
|
|
81
|
+
|
|
82
|
+
var pointIcon = {
|
|
83
|
+
path: 'M4 4m-4,0a4,4,0 0,1 8,0a 4,4 0 0,1 -8,0z',
|
|
84
|
+
fillColor: '#ffffff',
|
|
85
|
+
fillOpacity: 1,
|
|
86
|
+
anchor: new google.maps.Point(4, 4),
|
|
87
|
+
strokeWeight: 1,
|
|
88
|
+
strokeOpacity: 1,
|
|
89
|
+
strokeColor: '#303030',
|
|
90
|
+
scale: 1
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
var midPointIcon = {
|
|
94
|
+
path: 'M4 4m-4,0a4,4,0 0,1 8,0a 4,4 0 0,1 -8,0z',
|
|
95
|
+
fillColor: '#ffffff',
|
|
96
|
+
fillOpacity: 0.4,
|
|
97
|
+
anchor: new google.maps.Point(4, 4),
|
|
98
|
+
strokeWeight: 0.3,
|
|
99
|
+
strokeOpacity: 0.01,
|
|
100
|
+
strokeColor: '#303030',
|
|
101
|
+
scale: 1
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
var ghostPath = new google.maps.Polyline({
|
|
106
|
+
map: map,
|
|
107
|
+
strokeColor: '#ffa500',
|
|
108
|
+
strokeOpacity: 1,
|
|
109
|
+
strokeWeight: 3
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
function at(index){
|
|
113
|
+
return polygon.getPath().getAt(index);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function vertexGhostDragStart() {
|
|
117
|
+
|
|
118
|
+
var polygonBounds = new google.maps.LatLngBounds();
|
|
119
|
+
polygon.getPath().forEach(function (vertex, index) {
|
|
120
|
+
vertex.marker.setIcon(pointIcon);
|
|
121
|
+
polygonBounds.extend(vertex);
|
|
122
|
+
});
|
|
123
|
+
if(isMobile) {
|
|
124
|
+
var polygonBoundsCenter = polygonBounds.getCenter();
|
|
125
|
+
if(this.position.lat() >= polygonBoundsCenter.lat()) {
|
|
126
|
+
this.setIcon(handleIconUp);
|
|
127
|
+
} else {
|
|
128
|
+
this.setIcon(handleIconDown);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function vertexGhostDrag() {
|
|
134
|
+
if (ghostPath.getPath().getLength() === 0) {
|
|
135
|
+
if(this.marker.editIndex < polygon.getPath().getLength() - 1) {
|
|
136
|
+
ghostPath.setPath([
|
|
137
|
+
this.marker.getPosition(),
|
|
138
|
+
this.getPosition(),
|
|
139
|
+
at(this.marker.editIndex + 1)
|
|
140
|
+
]);
|
|
141
|
+
} else if(this.marker.editIndex == polygon.getPath().getLength() - 1) {
|
|
142
|
+
ghostPath.setPath([
|
|
143
|
+
this.marker.getPosition(),
|
|
144
|
+
this.getPosition(),
|
|
145
|
+
at(0)
|
|
146
|
+
]);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
ghostPath.getPath().setAt(1, this.getPosition());
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function moveGhostMarkers(marker) {
|
|
153
|
+
|
|
154
|
+
var vertex = at(marker.editIndex);
|
|
155
|
+
var previous, next, position;
|
|
156
|
+
|
|
157
|
+
if(marker.editIndex === 0) {
|
|
158
|
+
previous = at(polygon.getPath().getLength()-1);
|
|
159
|
+
} else {
|
|
160
|
+
previous = at(marker.editIndex - 1);
|
|
161
|
+
}
|
|
162
|
+
if(marker.editIndex == polygon.getPath().getLength()-1) {
|
|
163
|
+
next = at(0);
|
|
164
|
+
} else {
|
|
165
|
+
next = at(marker.editIndex + 1);
|
|
166
|
+
}
|
|
167
|
+
position = marker.getPosition();
|
|
168
|
+
|
|
169
|
+
if (vertex && vertex.ghostMarker) {
|
|
170
|
+
if (!google.maps.geometry) {
|
|
171
|
+
vertex.ghostMarker.setPosition(new google.maps.LatLng(vertex.lat() + 0.5 * (next.lat() - vertex.lat()), vertex.lng() + 0.5 * (next.lng() - vertex.lng())));
|
|
172
|
+
} else {
|
|
173
|
+
vertex.ghostMarker.setPosition(google.maps.geometry.spherical.interpolate(vertex, next, 0.5));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (previous && previous.ghostMarker) {
|
|
177
|
+
if (!google.maps.geometry) {
|
|
178
|
+
previous.ghostMarker.setPosition(new google.maps.LatLng(previous.lat() + 0.5 * (position.lat() - previous.lat()), previous.lng() + 0.5 * (position.lng() - previous.lng())));
|
|
179
|
+
} else {
|
|
180
|
+
previous.ghostMarker.setPosition(google.maps.geometry.spherical.interpolate(previous, position, 0.5));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function vertexGhostDragEnd() {
|
|
186
|
+
|
|
187
|
+
this.setIcon(midPointIcon);
|
|
188
|
+
|
|
189
|
+
var position = this.getPosition(),
|
|
190
|
+
index = this.marker.editIndex + 1,
|
|
191
|
+
vertex;
|
|
192
|
+
|
|
193
|
+
ghostPath.getPath().forEach(function() {
|
|
194
|
+
ghostPath.getPath().pop();
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
polygon.getPath().insertAt(index, position);
|
|
198
|
+
|
|
199
|
+
vertex = createMarkerVertex(at(index), pointIcon);
|
|
200
|
+
vertex.editIndex = index;
|
|
201
|
+
|
|
202
|
+
moveGhostMarkers(this.marker);
|
|
203
|
+
|
|
204
|
+
createGhostMarkerVertex(at(index));
|
|
205
|
+
|
|
206
|
+
polygon.getPath().forEach(function (vertex, index) {
|
|
207
|
+
if (vertex.marker) {
|
|
208
|
+
vertex.marker.editIndex = index;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
google.maps.event.trigger(polygon, 'insert_at', index, position);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function createGhostMarkerVertex(point) {
|
|
216
|
+
|
|
217
|
+
if (point.marker.editIndex < polygon.getPath().getLength() - 1) {
|
|
218
|
+
var next = at(point.marker.editIndex + 1),
|
|
219
|
+
position, vertex;
|
|
220
|
+
|
|
221
|
+
if (!google.maps.geometry) {
|
|
222
|
+
position = new google.maps.LatLng(point.lat() + 0.5 * (next.lat() - point.lat()), point.lng() + 0.5 * (next.lng() - point.lng()));
|
|
223
|
+
} else {
|
|
224
|
+
position = google.maps.geometry.spherical.interpolate(point, next, 0.5);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
vertex = point.ghostMarker;
|
|
228
|
+
|
|
229
|
+
if (!vertex){
|
|
230
|
+
vertex = new google.maps.Marker({
|
|
231
|
+
map: map,
|
|
232
|
+
icon: midPointIcon,
|
|
233
|
+
draggable: true,
|
|
234
|
+
raiseOnDrag: false
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
google.maps.event.addListener(vertex, "dragstart", vertexGhostDragStart);
|
|
238
|
+
google.maps.event.addListener(vertex, "drag", vertexGhostDrag);
|
|
239
|
+
google.maps.event.addListener(vertex, "dragend", vertexGhostDragEnd);
|
|
240
|
+
|
|
241
|
+
point.ghostMarker = vertex;
|
|
242
|
+
vertex.marker = point.marker;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
vertex.setPosition(position);
|
|
246
|
+
return vertex;
|
|
247
|
+
|
|
248
|
+
} else if (point.marker.editIndex == polygon.getPath().getLength() - 1) {
|
|
249
|
+
var next = at(0),
|
|
250
|
+
position, vertex;
|
|
251
|
+
|
|
252
|
+
if (!google.maps.geometry) {
|
|
253
|
+
position = new google.maps.LatLng(point.lat() + 0.5 * (next.lat() - point.lat()), point.lng() + 0.5 * (next.lng() - point.lng()));
|
|
254
|
+
} else {
|
|
255
|
+
position = google.maps.geometry.spherical.interpolate(point, next, 0.5);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
vertex = point.ghostMarker;
|
|
259
|
+
|
|
260
|
+
if (!vertex){
|
|
261
|
+
vertex = new google.maps.Marker({
|
|
262
|
+
map: map,
|
|
263
|
+
icon: midPointIcon,
|
|
264
|
+
draggable: true,
|
|
265
|
+
raiseOnDrag: false
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
google.maps.event.addListener(vertex, "dragstart", vertexGhostDragStart);
|
|
269
|
+
google.maps.event.addListener(vertex, "drag", vertexGhostDrag);
|
|
270
|
+
google.maps.event.addListener(vertex, "dragend", vertexGhostDragEnd);
|
|
271
|
+
|
|
272
|
+
point.ghostMarker = vertex;
|
|
273
|
+
vertex.marker = point.marker;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
vertex.setPosition(position);
|
|
277
|
+
return vertex;
|
|
278
|
+
|
|
279
|
+
}
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function vertexDragStart() {
|
|
284
|
+
var polygonBounds = new google.maps.LatLngBounds();
|
|
285
|
+
polygon.getPath().forEach(function (vertex, index) {
|
|
286
|
+
vertex.marker.setIcon(pointIcon);
|
|
287
|
+
polygonBounds.extend(vertex);
|
|
288
|
+
});
|
|
289
|
+
if(isMobile) {
|
|
290
|
+
var polygonBoundsCenter = polygonBounds.getCenter();
|
|
291
|
+
if(this.position.lat() >= polygonBoundsCenter.lat()) {
|
|
292
|
+
this.setIcon(handleIconUp);
|
|
293
|
+
} else {
|
|
294
|
+
this.setIcon(handleIconDown);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function vertexDrag() {
|
|
300
|
+
var vertex = this.getPosition();
|
|
301
|
+
vertex.marker = this;
|
|
302
|
+
vertex.ghostMarker = at(this.editIndex).ghostMarker;
|
|
303
|
+
polygon.getPath().setAt(this.editIndex, vertex);
|
|
304
|
+
moveGhostMarkers(this);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
function vertexDragEnd() {
|
|
308
|
+
google.maps.event.trigger(polygon, 'update_at', this.editIndex, this.getPosition());
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function vertexRightClick() {
|
|
312
|
+
var vertex = at(this.editIndex),
|
|
313
|
+
previous = at(this.editIndex - 1);
|
|
314
|
+
|
|
315
|
+
if (vertex.ghostMarker) {
|
|
316
|
+
vertex.ghostMarker.setMap(null);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
polygon.getPath().removeAt(this.editIndex);
|
|
320
|
+
|
|
321
|
+
if (previous) {
|
|
322
|
+
if (this.editIndex < polygon.getPath().getLength()) {
|
|
323
|
+
moveGhostMarkers(previous.marker);
|
|
324
|
+
} else {
|
|
325
|
+
previous.ghostMarker.setMap(null);
|
|
326
|
+
previous.ghostMarker = undefined;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
this.setMap(null);
|
|
331
|
+
polygon.getPath().forEach(function (vertex, index) {
|
|
332
|
+
if (vertex.marker) {
|
|
333
|
+
vertex.marker.editIndex = index;
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
if (polygon.getPath().getLength() === 1) {
|
|
338
|
+
polygon.getPath().pop().marker.setMap(null);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
google.maps.event.trigger(polygon, 'remove_at', this.editIndex, vertex);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function createMarkerVertex(point, icon) {
|
|
345
|
+
|
|
346
|
+
var vertex = point.marker;
|
|
347
|
+
|
|
348
|
+
if (!vertex){
|
|
349
|
+
|
|
350
|
+
vertex = new google.maps.Marker({
|
|
351
|
+
position: point,
|
|
352
|
+
map: map,
|
|
353
|
+
icon: icon,
|
|
354
|
+
draggable: true,
|
|
355
|
+
raiseOnDrag: false
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
google.maps.event.addListener(vertex, "dragstart", vertexDragStart);
|
|
359
|
+
google.maps.event.addListener(vertex, "drag", vertexDrag);
|
|
360
|
+
google.maps.event.addListener(vertex, "dragend", vertexDragEnd);
|
|
361
|
+
|
|
362
|
+
point.marker = vertex;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
vertex.setPosition(point);
|
|
366
|
+
|
|
367
|
+
return vertex;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function PolygonCustomEditWidget(map, polygon, currentPolygonCustomEdit, isMobile) {
|
|
371
|
+
|
|
372
|
+
polygon.setMap(map);
|
|
373
|
+
|
|
374
|
+
polygon.getPath().forEach(function (vertex, index) {
|
|
375
|
+
var mIcon = pointIcon;
|
|
376
|
+
if(isMobile && index === 1) {
|
|
377
|
+
mIcon = handleIconUp;
|
|
378
|
+
}
|
|
379
|
+
createMarkerVertex(vertex, mIcon).editIndex = index;
|
|
380
|
+
createGhostMarkerVertex(vertex);
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
currentPolygonCustomEdit = polygon;
|
|
384
|
+
|
|
385
|
+
return currentPolygonCustomEdit;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
PolygonCustomEditWidget.prototype = new google.maps.MVCObject();
|
|
389
|
+
|
|
390
|
+
return new PolygonCustomEditWidget(map, polygon, currentPolygonCustomEdit, isMobile);
|
|
391
|
+
|
|
392
|
+
};
|
|
393
|
+
}
|