-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html.save
234 lines (219 loc) · 8.73 KB
/
index.html.save
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1,width=device-width">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="css/leaflet.css">
<link rel="stylesheet" href="css/L.Control.Layers.Tree.css">
<link rel="stylesheet" href="css/qgis2web.css">
<link rel="stylesheet" href="css/fontawesome-all.min.css">
<style>
html, body, #map {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
</style>
<title>2022_衛星預估產量</title>
</head>
<body>
<div id="map">
</div>
<script src="js/qgis2web_expressions.js"></script>
<script src="js/leaflet.js"></script>
<script src="js/L.Control.Layers.Tree.min.js"></script>
<script src="js/leaflet.rotatedMarker.js"></script>
<script src="js/leaflet.pattern.js"></script>
<script src="js/leaflet-hash.js"></script>
<script src="js/Autolinker.min.js"></script>
<script src="js/rbush.min.js"></script>
<script src="js/labelgun.min.js"></script>
<script src="js/labels.js"></script>
<script src="js/leaflet.wms.js"></script>
<script src="data/Gy_A_rice_weight_UTMz51_1.js"></script>
<script>
var highlightLayer;
function highlightFeature(e) {
highlightLayer = e.target;
//radius = 100;
// console.log(e.latlng);
//L.circle([e.target.getCenter().lat,e.target.getCenter().lng], radius).addTo(map);
if (e.target.feature.geometry.type === 'LineString' || e.target.feature.geometry.type === 'MultiLineString') {
highlightLayer.setStyle({
color: '#ffff0f',
});
} else {
highlightLayer.setStyle({
fillColor: '#ffff00',
fillOpacity: 1
});
}
}
var map = L.map('map', {
zoomControl:false, maxZoom:28, minZoom:1
}).fitBounds([[24.69013990167979,121.80364150896582],[24.690963404516896,121.80496755608748]]);
var hash = new L.Hash(map);
map.attributionControl.setPrefix('<a href="https://github.com/tomchadwin/qgis2web" target="_blank">qgis2web</a> · <a href="https://leafletjs.com" title="A JS library for interactive maps">Leaflet</a> · <a href="https://qgis.org">QGIS</a>');
var autolinker = new Autolinker({truncate: {length: 30, location: 'smart'}});
// remove popup's row if "visible-with-data"
function removeEmptyRowsFromPopupContent(content, feature) {
var tempDiv = document.createElement('div');
tempDiv.innerHTML = content;
var rows = tempDiv.querySelectorAll('tr');
for (var i = 0; i < rows.length; i++) {
var td = rows[i].querySelector('td.visible-with-data');
var key = td ? td.id : '';
if (td && td.classList.contains('visible-with-data') && feature.properties[key] == null) {
rows[i].parentNode.removeChild(rows[i]);
}
}
return tempDiv.innerHTML;
}
// add class to format popup if it contains media
function addClassToPopupIfMedia(content, popup) {
var tempDiv = document.createElement('div');
tempDiv.innerHTML = content;
if (tempDiv.querySelector('td img')) {
popup._contentNode.classList.add('media');
// Delay to force the redraw
setTimeout(function() {
popup.update();
}, 10);
} else {
popup._contentNode.classList.remove('media');
}
}
var zoomControl = L.control.zoom({
position: 'topleft'
}).addTo(map);
var bounds_group = new L.featureGroup([]);
function setBounds() {
}
map.createPane('pane_TaiwaneMapnew_0');
map.getPane('pane_TaiwaneMapnew_0').style.zIndex = 400;
var layer_TaiwaneMapnew_0 = L.WMS.layer("http://maps.nlsc.gov.tw/S_Maps/wms", "EMAP97", {
pane: 'pane_TaiwaneMapnew_0',
format: 'image/png',
uppercase: true,
transparent: true,
continuousWorld : true,
tiled: true,
info_format: 'text/html',
opacity: 1,
identify: false,
attribution: '',
});
map.addLayer(layer_TaiwaneMapnew_0);
function pop_Gy_A_rice_weight_UTMz51_1(feature, layer) {
layer.on({
mouseout: function(e) {
for (var i in e.target._eventParents) {
if (typeof e.target._eventParents[i].resetStyle === 'function') {
e.target._eventParents[i].resetStyle(e.target);
}
}
},
mouseover: highlightFeature,
});
var popupContent = '<table>\
<tr>\
<td colspan="2">' + (feature.properties['PARCEL_NO'] !== null ? autolinker.link(feature.properties['PARCEL_NO'].toLocaleString()) : '') + '</td>\
</tr>\
<tr>\
<td colspan="2">' + (feature.properties['Phg_name'] !== null ? autolinker.link(feature.properties['Phg_name'].toLocaleString()) : '') + '</td>\
</tr>\
<tr>\
<th scope="row">產量<th>\
<td>' + (feature.properties['wieght_sum'] !== null ? autolinker.link(feature.properties['wieght_sum'].toLocaleString()) : '') + '</td>\
</tr>\
</table>';
var content = removeEmptyRowsFromPopupContent(popupContent, feature);
layer.on('popupopen', function(e) {
addClassToPopupIfMedia(content, e.popup);
});
layer.bindPopup(content, { maxHeight: 400 });
}
function style_Gy_A_rice_weight_UTMz51_1_0() {
return {
pane: 'pane_Gy_A_rice_weight_UTMz51_1',
opacity: 1,
color: 'rgba(35,35,35,1.0)',
dashArray: '',
lineCap: 'butt',
lineJoin: 'miter',
weight: 1.0,
fill: true,
fillOpacity: 1,
fillColor: 'rgba(244,233,153,1.0)',
interactive: true,
}
}
map.createPane('pane_Gy_A_rice_weight_UTMz51_1');
map.getPane('pane_Gy_A_rice_weight_UTMz51_1').style.zIndex = 401;
map.getPane('pane_Gy_A_rice_weight_UTMz51_1').style['mix-blend-mode'] = 'normal';
var layer_Gy_A_rice_weight_UTMz51_1 = new L.geoJson(json_Gy_A_rice_weight_UTMz51_1, {
attribution: '',
interactive: true,
dataVar: 'json_Gy_A_rice_weight_UTMz51_1',
layerName: 'layer_Gy_A_rice_weight_UTMz51_1',
pane: 'pane_Gy_A_rice_weight_UTMz51_1',
onEachFeature: pop_Gy_A_rice_weight_UTMz51_1,
style: style_Gy_A_rice_weight_UTMz51_1_0,
});
bounds_group.addLayer(layer_Gy_A_rice_weight_UTMz51_1);
map.addLayer(layer_Gy_A_rice_weight_UTMz51_1);
setBounds();
resetLabels([layer_Gy_A_rice_weight_UTMz51_1]);
map.on("zoomend", function(){
resetLabels([layer_Gy_A_rice_weight_UTMz51_1]);
});
map.on("layeradd", function(){
resetLabels([layer_Gy_A_rice_weight_UTMz51_1]);
});
map.on("layerremove", function(){
resetLabels([layer_Gy_A_rice_weight_UTMz51_1]);
});
/////
// click circle:
var clickCircle;
function onMapClick(e) {
console.log(e.latlng);
if (clickCircle != undefined) {
map.removeLayer(clickCircle);
};
// clickCircle = L.circle(e.latlng, 1609 * 3, {
// color: '#f07300',
// fillOpacity: 0,
// opacity: 0.5
// }).addTo(map);
clickCircle = L.circle(e.latlng, 100).addTo(map);
//
//featureGroup.clearLayers();
layer = e.layer;
// featureGroup.addLayer(layer);
// GetSelection(featureGroup);
console.log(feature.properties);
}
//// map.on('click', onMapClick);
map.on('click', onMapClick);
////////////
map.on('draw:created', function (e) {
console.log('draw:created');
featureGroup.clearLayers();
layer = e.layer;
featureGroup.addLayer(layer);
GetSelection(featureGroup);
});
function GetSelection(layer){
var shape2 = allPoints.toGeoJSON() //All facilities
var ptsWithin = turf.within(shape2, layer.toGeoJSON());
alert('Found ' + ptsWithin.features.length + ' features');
alert("results "+JSON.stringify(ptsWithin));
};
</script>
</body>
</html>