mapping-component-package-jp 0.1.55 → 0.2.0
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/package.json
CHANGED
|
@@ -35,6 +35,7 @@ export class MapOverlayManager {
|
|
|
35
35
|
|
|
36
36
|
// Rendering Methods
|
|
37
37
|
RenderFields(locations: any[], properties: any, editMode?: boolean): void;
|
|
38
|
+
RenderFieldsNew(locations: any[], properties: any, editMode?: boolean): void;
|
|
38
39
|
RenderRegionFarms(locationsJson: any, icon: any, fitBounds: boolean, offsetX: number, offsetY: number): void;
|
|
39
40
|
RenderRegions(regionLocations: any[], properties: any, farmLocations: any[], icon: any, offsetX: number, offsetY: number): void;
|
|
40
41
|
RenderBackgroundFields(locations: any[], properties: any): void;
|
|
@@ -335,6 +335,28 @@ export class MapOverlayManager {
|
|
|
335
335
|
return map.overlayMapTypes;
|
|
336
336
|
}
|
|
337
337
|
|
|
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
|
+
}
|
|
338
360
|
|
|
339
361
|
//#DRAW/DISPLAY FIELDS
|
|
340
362
|
_this.RenderFields = function (locations, properties) {
|
|
@@ -399,6 +421,71 @@ export class MapOverlayManager {
|
|
|
399
421
|
polygonsToMap_set();
|
|
400
422
|
};
|
|
401
423
|
|
|
424
|
+
//#DRAW/DISPLAY FIELDS
|
|
425
|
+
_this.RenderFieldsNew = function (locations, properties) {
|
|
426
|
+
var mbounds = new google.maps.LatLngBounds();
|
|
427
|
+
|
|
428
|
+
locations.forEach(function (location) {
|
|
429
|
+
if (location && location.Poly && location.Poly.length > 0 && location.Id.length > 0) {
|
|
430
|
+
var paths = location.Poly.map(poly => poly.map(v => new google.maps.LatLng(parseFloat(v[1]), parseFloat(v[0]))));
|
|
431
|
+
paths[0].forEach(coord => mbounds.extend(coord));
|
|
432
|
+
|
|
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
|
+
var polygonOptions = {
|
|
446
|
+
paths: paths,
|
|
447
|
+
id: location.Id,
|
|
448
|
+
content: content
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
if (location.MapLocationFeature) {
|
|
452
|
+
polygonOptions = {
|
|
453
|
+
...polygonOptions,
|
|
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
|
+
};
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
var polygon = new google.maps.Polygon(polygonOptions);
|
|
472
|
+
polygons.push(polygon);
|
|
473
|
+
if (properties.labelVisable) AddLabel(location);
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
polygonsToMap_setNew();
|
|
478
|
+
|
|
479
|
+
map.fitBounds(mbounds);
|
|
480
|
+
|
|
481
|
+
fields_BindPolyEvents();
|
|
482
|
+
|
|
483
|
+
if(properties.icon){
|
|
484
|
+
AdvancedMarker(locations, properties.icon);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
};
|
|
488
|
+
|
|
402
489
|
_this.destroy = function () {
|
|
403
490
|
mapId = null;
|
|
404
491
|
mapConfig = null;
|