Explorar el Código

修改 縮小圖示

manto07m hace 3 años
padre
commit
401a798e7e
Se han modificado 1 ficheros con 52 adiciones y 9 borrados
  1. 52 9
      index.php

+ 52 - 9
index.php

@@ -386,11 +386,20 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 					id: "6b4e83dd94c4410db4bece82262b2573"
 
 				},
-				opacity: .75,
+				opacity: 1,
 				showAttribution: false,
 
 			});
 
+			const simpleMakerRenderer = {
+				type: "unique-value",
+				legendOptions: {
+					title: "工程類別"
+				},
+				field: "工程類別",
+				uniqueValueInfos: getUniqueValueInfos2(),
+			};
+
 			const typeRenderer = {
 				type: "unique-value",
 				legendOptions: {
@@ -421,6 +430,28 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 				}
 				return array;
 			}
+
+			function getUniqueValueInfos2() {
+				var array = [];
+				for (const [key, value] of Object.entries(color)) {
+					let data = JSON.parse(`{
+						"value": "${key}",
+						"label": "${key}",
+						"symbol": {
+							"type": "simple-marker",
+							"color": "${value}",
+							"size": 12,
+							"outline": {
+								"color": "#00FFFF",
+								"width": 2
+							}
+						}
+					}`);
+					array.push(data);
+				}
+				return array;
+			}
+
 			const labelClass = {
 				// autocasts as new LabelClass()
 				symbol: {
@@ -441,7 +472,7 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 				// labelPlacement: "above-center",
 			};
 
-			var featureLayer = new FeatureLayer({
+			var projectLayer = new FeatureLayer({
 
 				url: "https://services3.arcgis.com/W6g8dmWX0ILAHcNd/arcgis/rest/services/%E5%B7%A5%E7%A8%8B%E8%A8%AD%E8%A8%88%E8%B3%87%E6%96%99%E5%BA%AB/FeatureServer",
 				outFields: ["*"],
@@ -449,12 +480,14 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 				title: "工程設計資料庫",
 				elevationInfo: "on-the-ground",
 				visible: true,
-				opacity: 0.5,
+				opacity: 0.8,
 				renderer: typeRenderer,
 				labelingInfo: [labelClass],
 			});
-			featureLayer.listMode = "hide";
-			webscene.add(featureLayer);
+			projectLayer.listMode = "hide";
+			webscene.add(projectLayer);
+
+			const projectRenderer = projectLayer.render;
 
 			const wmts1 = new WMTSLayer({
 				url: "https://wmts.nlsc.gov.tw/wmts",
@@ -758,6 +791,16 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 				});
 			}
 
+			view.watch("scale", (newValue) => {
+				if (newValue > 30000) {
+					projectLayer.labelsVisible = true;
+					projectLayer.renderer = simpleMakerRenderer;
+				} else {
+					projectLayer.labelsVisible = false;
+					projectLayer.renderer = typeRenderer;
+				}
+			});
+
 			view.when(function() {
 				layerList.on("trigger-action", (event) => {
 
@@ -784,23 +827,23 @@ include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_
 
 
 			// highlight is set on the layerView, so we need to detect when the layerView is ready
-			view.whenLayerView(featureLayer).then((layerView) => {
+			view.whenLayerView(projectLayer).then((layerView) => {
 				// creates the query that will be used to obtain the features needed for the highlight
-				const queryStations = featureLayer.createQuery();
+				const queryStations = projectLayer.createQuery();
 				// features that are passed in the highlight function need to have an `objectID`
 				// if the query is built using `new Query()` then `queryStations.outFields = ["objectID"]` should be set
 
 				$('#treeAjaxHTML').on("select_node.jstree", function(e, data) {
 					if (data.node.text.includes("-")) {
 						project_id = data.node.text.split("-")[0];
-						featureLayer.definitionExpression = "計畫編號 = '" + project_id + "'";
+						projectLayer.definitionExpression = "計畫編號 = '" + project_id + "'";
 						zoomToLayer(project_id);
 					}
 				});
 
 				function zoomToLayer(project_id) {
 					queryStations.where = `計畫編號='${project_id}'`;
-					featureLayer.queryFeatures(queryStations).then((result) => {
+					projectLayer.queryFeatures(queryStations).then((result) => {
 						// if a feature is already highlighted, then remove the highlight
 						if (highlightSelect) {
 							highlightSelect.remove();