mapping-component-package-jp 0.2.0 → 0.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapping-component-package-jp",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -35,7 +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
+ 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;
@@ -144,6 +150,14 @@ export class MapOverlayManager {
144
150
  });
145
151
  }
146
152
 
153
+ function fields_BindPolyEventsMobile() {
154
+ polygons.forEach(function (poly) {
155
+ polygonListeners.push(google.maps.event.addListener(poly, 'click', function (event) {
156
+ eventHandlers["FieldOnClick"](this.id);
157
+ }));
158
+ });
159
+ }
160
+
147
161
  function farms_BindMarkerEvents() {
148
162
  deleteTooltip();
149
163
  fmarkers.forEach(function (marker) {
@@ -335,30 +349,6 @@ export class MapOverlayManager {
335
349
  return map.overlayMapTypes;
336
350
  }
337
351
 
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
352
  _this.RenderFields = function (locations, properties) {
363
353
  var mbounds = new google.maps.LatLngBounds();
364
354
 
@@ -421,8 +411,7 @@ export class MapOverlayManager {
421
411
  polygonsToMap_set();
422
412
  };
423
413
 
424
- //#DRAW/DISPLAY FIELDS
425
- _this.RenderFieldsNew = function (locations, properties) {
414
+ _this.RenderFieldsMobile = function (locations) {
426
415
  var mbounds = new google.maps.LatLngBounds();
427
416
 
428
417
  locations.forEach(function (location) {
@@ -430,60 +419,29 @@ export class MapOverlayManager {
430
419
  var paths = location.Poly.map(poly => poly.map(v => new google.maps.LatLng(parseFloat(v[1]), parseFloat(v[0]))));
431
420
  paths[0].forEach(coord => mbounds.extend(coord));
432
421
 
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
422
 
445
423
  var polygonOptions = {
446
424
  paths: paths,
447
425
  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
- };
426
+ strokeColor: location.MapLocationFeature.StrokeColor,
427
+ strokeOpacity: location.MapLocationFeature.StrokeOpacity,
428
+ strokeWeight: location.MapLocationFeature.StrokeWeight,
429
+ fillColor: location.MapLocationFeature.FillColor,
430
+ fillOpacity: location.MapLocationFeature.FillOpacity,
431
+ zIndex: location.MapLocationFeature.ZIndex
469
432
  }
470
433
 
471
434
  var polygon = new google.maps.Polygon(polygonOptions);
472
435
  polygons.push(polygon);
473
- if (properties.labelVisable) AddLabel(location);
474
436
  }
475
437
  });
476
438
 
477
- polygonsToMap_setNew();
439
+ polygonsToMapMobile_set();
478
440
 
479
441
  map.fitBounds(mbounds);
480
442
 
481
- fields_BindPolyEvents();
443
+ fields_BindPolyEventsMobile();
482
444
 
483
- if(properties.icon){
484
- AdvancedMarker(locations, properties.icon);
485
- }
486
-
487
445
  };
488
446
 
489
447
  _this.destroy = function () {