mapping-component-package-jp 0.2.4 → 0.2.6

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.4",
3
+ "version": "0.2.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -93,4 +93,52 @@ function formatBlockLabel(Id, locname, locarea, fontSize) {
93
93
  return { nameWidth: nameWidth, areaWidth: areaWidth };
94
94
  }
95
95
 
96
- export { projectMercator, tile2latLng, diffLatLng2Meters, formatBlockLabel, get_FillColorOpacity, get_FillColor }
96
+ function formatBlockLabelMobile(Id, locname, locarea, fontFamily, fontSize, fontWeight) {
97
+ var ne = document.createElement("div");
98
+ ne.id = 'locname' + Id;
99
+ ne.style.display = "inline-block";
100
+ ne.style.fontFamily = fontFamily;
101
+ ne.style.fontSize = fontSize + 'px';
102
+ ne.style.fontWeight = fontWeight;
103
+ ne.textContent = locname;
104
+
105
+ var ae = document.createElement("div");
106
+ ae.id = 'locarea' + Id;
107
+ ae.style.display = "inline-block";
108
+ ae.style.fontFamily = fontFamily;
109
+ ae.style.fontSize = fontSize + 'px';
110
+ ne.style.fontWeight = fontWeight;
111
+ ae.textContent = locarea;
112
+
113
+ var nce = document.createElement("div");
114
+ nce.id = 'locnameContainer' + Id;
115
+ nce.style.position = "absolute";
116
+ nce.style.top = "0";
117
+ nce.style.left = "-1000px";
118
+
119
+ var ace = document.createElement("div");
120
+ ace.id = 'locareaContainer' + Id;
121
+ ace.style.position = "absolute";
122
+ ace.style.top = "0";
123
+ ace.style.left = "-1000px";
124
+
125
+ nce.appendChild(ne);
126
+ ace.appendChild(ae);
127
+ document.body.appendChild(nce);
128
+ document.body.appendChild(ace);
129
+
130
+ var nameElem = document.getElementById('locname' + Id);
131
+ var areaElem = document.getElementById('locarea' + Id);
132
+ var nameContainerElem = document.getElementById('locnameContainer' + Id);
133
+ var areaContainerElem = document.getElementById('locareaContainer' + Id);
134
+
135
+ var nameWidth = nameElem.clientWidth;
136
+ var areaWidth = areaElem.clientWidth;
137
+
138
+ nameContainerElem.remove();
139
+ areaContainerElem.remove();
140
+
141
+ return { nameWidth: nameWidth, areaWidth: areaWidth };
142
+ }
143
+
144
+ export { projectMercator, tile2latLng, diffLatLng2Meters, formatBlockLabel, formatBlockLabelMobile, get_FillColorOpacity, get_FillColor }
@@ -1,4 +1,4 @@
1
- import { diffLatLng2Meters, formatBlockLabel, get_FillColorOpacity, get_FillColor } from './map.common';
1
+ import { diffLatLng2Meters, formatBlockLabel, formatBlockLabelMobile, get_FillColorOpacity, get_FillColor } from './map.common';
2
2
  import { ClearHTML } from '../../utils/mapUtils';
3
3
  import { circleToPolygon } from './circle.functions';
4
4
  import { IQLPolygonCustomEdit } from './shapes/polygon.customedit';
@@ -131,20 +131,30 @@ export class MapOverlayManager {
131
131
  var labelLat = polyCentroidCenter.y;
132
132
  var labelLon = polyCentroidCenter.x;
133
133
  var areaText = `${location.Area} ha`;
134
- var bl = formatBlockLabel(location.Id, location.LocationName, areaText, 8);
134
+ var bl = formatBlockLabelMobile(
135
+ location.Id,
136
+ location.LocationName,
137
+ areaText,
138
+ location.LabelFontFamily,
139
+ location.LabelFontSize,
140
+ location.LabelFontWeight,
141
+ );
135
142
 
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>`;
143
+ var svgText = '<svg width="'+bl.nameWidth+'" height="'+location.LabelFontSize+'" viewBox="0 0 '+bl.nameWidth+' '+location.LabelFontSize+'" xmlns="http://www.w3.org/2000/svg">';
144
+ svgText += '<text x="0" y="'+location.LabelFontSize+'" fill="'+location.LabelColor+'" font-family="'+location.LabelFontFamily+'" font-size="'+location.LabelFontSize+'px" font-weight="'+location.LabelFontWeight+'">'+location.LocationName+'</text>';
145
+ svgText += '</svg>';
146
+
147
+ console.log('svgText', svgText);
139
148
 
140
149
  var polyLabel = new google.maps.Marker({
141
150
  map: map,
142
151
  position: new google.maps.LatLng(parseFloat(labelLat), parseFloat(labelLon)),
143
152
  icon: {
144
- anchor: new google.maps.Point(bl.nameWidth / 2, 21),
153
+ anchor: new google.maps.Point(bl.nameWidth / 2, location.LabelFontSize),
145
154
  url: `data:image/svg+xml;utf-8, ${svgText}`
146
155
  },
147
- id: `pl_${location.Id}`
156
+ id: `pl_${location.Id}`,
157
+ zIndex: location.LabelZIndex
148
158
  });
149
159
  polyLabels.push(polyLabel);
150
160
  }
@@ -454,7 +464,7 @@ export class MapOverlayManager {
454
464
  zIndex: location.MapLocationFeature.ZIndex
455
465
  }
456
466
 
457
- if (location.showLabel) AddLabelMobile(location);
467
+ if (location.ShowLabel) AddLabelMobile(location);
458
468
 
459
469
  var polygon = new google.maps.Polygon(polygonOptions);
460
470
  polygons.push(polygon);