mapping-component-package-jp 0.1.54 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapping-component-package-jp",
3
- "version": "0.1.54",
3
+ "version": "0.2.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -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;
@@ -185,6 +185,7 @@ export class MapOverlayManager {
185
185
  tipObj.innerHTML = data;
186
186
  tipObj.style.top = event.domEvent.clientY + window.scrollY + ttOffset.y + "px";
187
187
  tipObj.style.left = event.domEvent.clientX + window.scrollX + ttOffset.x + "px";
188
+ tipObj.style.zIndex = 20000;
188
189
  document.body.appendChild(tipObj);
189
190
  }
190
191
  }
@@ -196,6 +197,7 @@ export class MapOverlayManager {
196
197
  tipObj.innerHTML = data;
197
198
  tipObj.style.top = event.clientY + window.scrollY + ttOffset.y + "px";
198
199
  tipObj.style.left = event.clientX + window.scrollX + ttOffset.x + "px";
200
+ tipObj.style.zIndex = 20000;
199
201
  document.body.appendChild(tipObj);
200
202
  }
201
203
  }
@@ -333,6 +335,28 @@ export class MapOverlayManager {
333
335
  return map.overlayMapTypes;
334
336
  }
335
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
+ }
336
360
 
337
361
  //#DRAW/DISPLAY FIELDS
338
362
  _this.RenderFields = function (locations, properties) {
@@ -397,6 +421,71 @@ export class MapOverlayManager {
397
421
  polygonsToMap_set();
398
422
  };
399
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
+
400
489
  _this.destroy = function () {
401
490
  mapId = null;
402
491
  mapConfig = null;