mapping-component-package-jp 0.2.0 → 0.2.3
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/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/js/mapEncapsulation/mapOverlayManager.d.ts +1 -1
- package/src/js/mapEncapsulation/mapOverlayManager.js +48 -65
package/package.json
CHANGED
|
@@ -35,7 +35,7 @@ export class MapOverlayManager {
|
|
|
35
35
|
|
|
36
36
|
// Rendering Methods
|
|
37
37
|
RenderFields(locations: any[], properties: any, editMode?: boolean): void;
|
|
38
|
-
|
|
38
|
+
RenderFieldsMobile(locations: any[]): void;
|
|
39
39
|
RenderRegionFarms(locationsJson: any, icon: any, fitBounds: boolean, offsetX: number, offsetY: number): void;
|
|
40
40
|
RenderRegions(regionLocations: any[], properties: any, farmLocations: any[], icon: any, offsetX: number, offsetY: number): void;
|
|
41
41
|
RenderBackgroundFields(locations: any[], properties: any): void;
|
|
@@ -95,6 +95,12 @@ export class MapOverlayManager {
|
|
|
95
95
|
mapListeners.push(zoomChangedListener);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
function polygonsToMapMobile_set() {
|
|
99
|
+
polygons.forEach(function (p) {
|
|
100
|
+
p.setMap(map);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
98
104
|
function AddLabel(location, labelColour = "white") {
|
|
99
105
|
var polyCentroidCenter = get_polygon_centroid(location.Poly);
|
|
100
106
|
var labelLat = polyCentroidCenter.y;
|
|
@@ -120,6 +126,29 @@ export class MapOverlayManager {
|
|
|
120
126
|
polyLabels.push(polyLabel);
|
|
121
127
|
}
|
|
122
128
|
|
|
129
|
+
function AddLabelMobile(location) {
|
|
130
|
+
var polyCentroidCenter = get_polygon_centroid(location.Poly);
|
|
131
|
+
var labelLat = polyCentroidCenter.y;
|
|
132
|
+
var labelLon = polyCentroidCenter.x;
|
|
133
|
+
var areaText = `${location.Area} ha`;
|
|
134
|
+
var bl = formatBlockLabel(location.Id, location.LocationName, areaText, 8);
|
|
135
|
+
|
|
136
|
+
var svgText = `<svg viewBox="0 0 200 30" xmlns="http://www.w3.org/2000/svg">
|
|
137
|
+
<text x="0" y="12" fill="${location.LabelColor}" font-family="Arial, sans-serif" font-size="8px">${ClearHTML.clearString(location.LocationName)}</text>
|
|
138
|
+
</svg>`;
|
|
139
|
+
|
|
140
|
+
var polyLabel = new google.maps.Marker({
|
|
141
|
+
map: map,
|
|
142
|
+
position: new google.maps.LatLng(parseFloat(labelLat), parseFloat(labelLon)),
|
|
143
|
+
icon: {
|
|
144
|
+
anchor: new google.maps.Point(bl.nameWidth / 2, 21),
|
|
145
|
+
url: `data:image/svg+xml;utf-8, ${svgText}`
|
|
146
|
+
},
|
|
147
|
+
id: `pl_${location.Id}`
|
|
148
|
+
});
|
|
149
|
+
polyLabels.push(polyLabel);
|
|
150
|
+
}
|
|
151
|
+
|
|
123
152
|
function get_polygon_centroid(points) {
|
|
124
153
|
var centroid = polylabel(points, 0.00001);
|
|
125
154
|
return { x: centroid[0], y: centroid[1] };
|
|
@@ -144,6 +173,14 @@ export class MapOverlayManager {
|
|
|
144
173
|
});
|
|
145
174
|
}
|
|
146
175
|
|
|
176
|
+
function fields_BindPolyEventsMobile() {
|
|
177
|
+
polygons.forEach(function (poly) {
|
|
178
|
+
polygonListeners.push(google.maps.event.addListener(poly, 'click', function (event) {
|
|
179
|
+
eventHandlers["FieldOnClick"](this.id);
|
|
180
|
+
}));
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
147
184
|
function farms_BindMarkerEvents() {
|
|
148
185
|
deleteTooltip();
|
|
149
186
|
fmarkers.forEach(function (marker) {
|
|
@@ -335,30 +372,6 @@ export class MapOverlayManager {
|
|
|
335
372
|
return map.overlayMapTypes;
|
|
336
373
|
}
|
|
337
374
|
|
|
338
|
-
function polygonsToMap_setNew() {
|
|
339
|
-
[...polygons, ...locPolygons].forEach(p => p.setMap(map));
|
|
340
|
-
|
|
341
|
-
const showLabels = map.getZoom() >= 13;
|
|
342
|
-
polyLabels.forEach(pl => pl.setMap(showLabels ? map : null));
|
|
343
|
-
|
|
344
|
-
if (zoomChangedListener) {
|
|
345
|
-
google.maps.event.removeListener(zoomChangedListener);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
zoomChangedListener = map.addListener('zoom_changed', function () {
|
|
349
|
-
const currentZoom = map.getZoom();
|
|
350
|
-
const shouldShow = currentZoom >= 13;
|
|
351
|
-
|
|
352
|
-
polyLabels.forEach(pl => {
|
|
353
|
-
if (shouldShow && !pl.getMap()) pl.setMap(map);
|
|
354
|
-
if (!shouldShow && pl.getMap()) pl.setMap(null);
|
|
355
|
-
});
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
mapListeners.push(zoomChangedListener);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
//#DRAW/DISPLAY FIELDS
|
|
362
375
|
_this.RenderFields = function (locations, properties) {
|
|
363
376
|
var mbounds = new google.maps.LatLngBounds();
|
|
364
377
|
|
|
@@ -421,8 +434,7 @@ export class MapOverlayManager {
|
|
|
421
434
|
polygonsToMap_set();
|
|
422
435
|
};
|
|
423
436
|
|
|
424
|
-
|
|
425
|
-
_this.RenderFieldsNew = function (locations, properties) {
|
|
437
|
+
_this.RenderFieldsMobile = function (locations) {
|
|
426
438
|
var mbounds = new google.maps.LatLngBounds();
|
|
427
439
|
|
|
428
440
|
locations.forEach(function (location) {
|
|
@@ -430,60 +442,31 @@ export class MapOverlayManager {
|
|
|
430
442
|
var paths = location.Poly.map(poly => poly.map(v => new google.maps.LatLng(parseFloat(v[1]), parseFloat(v[0]))));
|
|
431
443
|
paths[0].forEach(coord => mbounds.extend(coord));
|
|
432
444
|
|
|
433
|
-
let content = `${location.FarmName} - ${location.LocationName}<br>${location.Area} ha${location.IsIrrigated ? ', irrigated' : ''}`;
|
|
434
|
-
|
|
435
|
-
if (location.CropPlanted) {
|
|
436
|
-
content += `<br>${location.CropPlanted}`;
|
|
437
|
-
if (location.CultivarPlanted) {
|
|
438
|
-
content += ` (${location.CultivarPlanted})`;
|
|
439
|
-
}
|
|
440
|
-
if (location.PlantingDate) {
|
|
441
|
-
content += `<br>Planted: ${location.PlantingDate.replace(/-/g, "/")}`;
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
445
|
|
|
445
446
|
var polygonOptions = {
|
|
446
447
|
paths: paths,
|
|
447
448
|
id: location.Id,
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
content,
|
|
455
|
-
strokeColor: location.MapLocationFeature.StrokeColor,
|
|
456
|
-
strokeOpacity: location.MapLocationFeature.StrokeOpacity,
|
|
457
|
-
strokeWeight: location.MapLocationFeature.StrokeWeight,
|
|
458
|
-
fillColor: location.MapLocationFeature.FillColor,
|
|
459
|
-
fillOpacity: location.MapLocationFeature.FillOpacity,
|
|
460
|
-
zIndex: location.MapLocationFeature.ZIndex
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
else
|
|
464
|
-
{
|
|
465
|
-
polygonOptions = {
|
|
466
|
-
...polygonOptions,
|
|
467
|
-
...properties.polygonOptions.unselected,
|
|
468
|
-
};
|
|
449
|
+
strokeColor: location.MapLocationFeature.StrokeColor,
|
|
450
|
+
strokeOpacity: location.MapLocationFeature.StrokeOpacity,
|
|
451
|
+
strokeWeight: location.MapLocationFeature.StrokeWeight,
|
|
452
|
+
fillColor: location.MapLocationFeature.FillColor,
|
|
453
|
+
fillOpacity: location.MapLocationFeature.FillOpacity,
|
|
454
|
+
zIndex: location.MapLocationFeature.ZIndex
|
|
469
455
|
}
|
|
456
|
+
|
|
457
|
+
if (properties.showLabel) AddLabelMobile(location);
|
|
470
458
|
|
|
471
459
|
var polygon = new google.maps.Polygon(polygonOptions);
|
|
472
460
|
polygons.push(polygon);
|
|
473
|
-
if (properties.labelVisable) AddLabel(location);
|
|
474
461
|
}
|
|
475
462
|
});
|
|
476
463
|
|
|
477
|
-
|
|
464
|
+
polygonsToMapMobile_set();
|
|
478
465
|
|
|
479
466
|
map.fitBounds(mbounds);
|
|
480
467
|
|
|
481
|
-
|
|
468
|
+
fields_BindPolyEventsMobile();
|
|
482
469
|
|
|
483
|
-
if(properties.icon){
|
|
484
|
-
AdvancedMarker(locations, properties.icon);
|
|
485
|
-
}
|
|
486
|
-
|
|
487
470
|
};
|
|
488
471
|
|
|
489
472
|
_this.destroy = function () {
|