mapping-component-package-jp 0.2.5 → 0.2.7
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
|
@@ -93,4 +93,52 @@ function formatBlockLabel(Id, locname, locarea, fontSize) {
|
|
|
93
93
|
return { nameWidth: nameWidth, areaWidth: areaWidth };
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
|
|
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+1, areaWidth: areaWidth+1 };
|
|
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,24 +131,28 @@ 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 =
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
var bl = formatBlockLabelMobile(
|
|
135
|
+
location.Id,
|
|
136
|
+
location.LocationName,
|
|
137
|
+
areaText,
|
|
138
|
+
location.LabelFontFamily,
|
|
139
|
+
location.LabelFontSize,
|
|
140
|
+
location.LabelFontWeight,
|
|
141
|
+
);
|
|
137
142
|
|
|
138
|
-
var svgText =
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
console.log('svgText', svgText);
|
|
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>';
|
|
143
146
|
|
|
144
147
|
var polyLabel = new google.maps.Marker({
|
|
145
148
|
map: map,
|
|
146
149
|
position: new google.maps.LatLng(parseFloat(labelLat), parseFloat(labelLon)),
|
|
147
150
|
icon: {
|
|
148
|
-
anchor: new google.maps.Point(bl.nameWidth / 2,
|
|
151
|
+
anchor: new google.maps.Point(bl.nameWidth / 2, location.LabelFontSize),
|
|
149
152
|
url: `data:image/svg+xml;utf-8, ${svgText}`
|
|
150
153
|
},
|
|
151
|
-
id: `pl_${location.Id}
|
|
154
|
+
id: `pl_${location.Id}`,
|
|
155
|
+
zIndex: location.LabelZIndex
|
|
152
156
|
});
|
|
153
157
|
polyLabels.push(polyLabel);
|
|
154
158
|
}
|