Best JavaScript code snippet using chai
GisMapTools.js
Source:GisMapTools.js  
1// å°å¾è¾
å©ç±»2var GisMapTools = {3	// geometry:æ¡é/åé group:åç»éæ©4	selectType: "",5	// å½åéåºåæ ä¿¡æ¯6	currGeometry: "",7	// å½åçæ§ç¹çä¿¡æ¯8	currentCamera: null,9	// å½åéä¸çç»10	groupObj: null,11	clusterLayer: null,12	//æç´¢ç»æå¾å±13	searchResultLayer: "",14	//æ¯å¦å·²ç¹å»å°å¾æ æ³¨15	isOnClickGraphic: false,16	//æ æ³¨æ°17	markerCount: 0,18	//æ æ³¨ååå
ç´ 19	markerCircle: null,20	//æ æ³¨ååå
ç´ éç½®ä½ç½®æé®21	markerCircleResizeBtn: null,22	//æ æ³¨åå¾æç¤ºè¯23	markerCircleRadius: null,24	//æç¤ºè¯25	markerCircleRadiusText: null,26	//å°å¾ææ½äºä»¶27	mapMouseDragHandle: null,28	//æ æ³¨ä¸å¿ç¹åæ 29	markerCenter: null,30	//æ æ³¨ææ½ç»æåæ 31	markerDragEnd: null,32	wgs: new esri.SpatialReference({33		"wkid":   10210034	}),35	initialize: function(){36		this.registerHelper();37	},38	// éæ©å°åº39	selectPlace: function(obj) {40		var This = jQuery(obj),41			Next = This.next();42		if (Next.is(":hidden")) {43			Next.fadeIn(200);44		} else if (Next.is(":visible")) {45			Next.fadeOut(200);46		}47		jQuery(".map-select-list").fadeOut(200);48		jQuery("#mapSearchAroundContent").fadeOut(200);49	},50	// éæ©åºå䏿å表51	selectMap: function(obj) {52		var This = jQuery(obj),53			Next = This.next();54		if (Next.is(":hidden")) {55			Next.fadeIn(200);56		} else if (Next.is(":visible")) {57			Next.fadeOut(200);58		}59		jQuery(".map-region-info").fadeOut(200);60		jQuery("#mapSearchAroundContent").fadeOut(200);61	},62	// éèæç´¢åºåå
容63	hideSearchAroundContent: function(obj) {64		var This = jQuery(obj);65		This.parent().fadeOut(200);66	},67	// è·åææççæ§ç¹68	getAllCameras: function() {69		jQuery.ajax({70			url: '/service/map/map_all_cameras',71			type: 'post',72			dataType: 'json',73			success: function(res) {74				if (res.code === 200) {75					GisMapTools.clusterCameras(res.data.cameras);76				} else if (res.code === 500) {77					notify.error(res.data.message);78				} else {79					notify.error("è·åæ°æ®å¼å¸¸ï¼");80				}81			},82			error: function() {83				notify.error("请æ¥çç½ç»ç¶åµï¼");84			}85		});86	},87	// èåçæ§ç¹88	clusterCameras: function(datas) {89		var camerasInfo = {};90		require(["dojo/_base/array", "dojo/ClusterLayer"], function(array, ClusterLayer) {91			camerasInfo.data = array.map(datas, function(p) {92				var webMercator = new esri.geometry.Point(parseFloat(p.longitude), parseFloat(p.latitude), GisMapTools.wgs);93				if (mapConfig.coorTransform) {94					webMercator = esri.geometry.geographicToWebMercator(webMercator);95				}96				return {97					"x": webMercator.x,98					"y": webMercator.y,99					"attributes": p100				};101			});102			GisMapTools.clusterLayer = new ClusterLayer({103				"data": camerasInfo.data,104				"id": "clusters",105				"distance": 100,106				"labelColor": "#fff",107				"labelOffset": 10,108				"resolution": InspectMap.extent.getWidth() / InspectMap.width,109				"singleColor": "#F9927F",110				"spatialReference": GisMapTools.wgs,111				"singleTemplate": new esri.InfoTemplate({112					"title": "",113					"content": ""114				})115				//"singleSymbol": new esri.symbol.PictureMarkerSymbol("/assets/images/map/simple-marker.gif", 10, 13)116			});117			// cluster layer that uses OpenLayers style clustering118			var defaultSym = new esri.symbol.SimpleMarkerSymbol().setSize(4);119			var renderer = new esri.renderer.ClassBreaksRenderer(defaultSym, "clusterCount");120			var blue = new esri.symbol.PictureMarkerSymbol("/assets/images/map/camera-ball.png", 12, 14);121			var cluster1 = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-cluster-1.png", 20, 23).setOffset(1, 12),122				cluster2 = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-cluster-2.png", 30, 23).setOffset(1, 12),123				cluster3 = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-cluster-3.png", 34, 23).setOffset(1, 12),124				cluster4 = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-cluster-4.png", 40, 23).setOffset(1, 12);125			renderer.addBreak(0, 2, blue);126			renderer.addBreak(2, 100, cluster1);127			renderer.addBreak(100, 1000, cluster2);128			renderer.addBreak(1000, 10000, cluster3);129			renderer.addBreak(10000, 100000, cluster4);130			GisMapTools.clusterLayer.setRenderer(renderer);131			InspectMap.addLayer(GisMapTools.clusterLayer);132			// close the info window when the map is clicked133			InspectMap.on("click", GisMapTools.cleanUp);134			// close the info window when esc is pressed135			InspectMap.on("key-down", function(e) {136				if (e.keyCode === 27) {137					GisMapTools.cleanUp();138				}139			});140		});141	},142	// æ¸
é¤èå143	cleanUp: function() {144		//InspectMap.infoWindow.hide();145		GisMapTools.clusterLayer.clearSingles();146	},147	//éèæç¤ºä¿¡æ¯148	hideTooltip: function() {149		jQuery("#gismap .map-measure-tooltip").css("left", "-2000px");150		jQuery("#gismap").unbind("mousemove");151	},152	//æ¾ç¤ºæç¤ºä¿¡æ¯153	getTooltipPosition: function(evt) {154		var top, left;155		var ie = navigator.userAgent.indexOf("MSIE") > 0;156		var isFullscreen = (parseInt(jQuery("#major").css("left")) <= 0) ? true : false;157		if (ie) {158			if (isFullscreen) {159				left = parseInt(evt.clientX);160				top = parseInt(evt.clientY + 20);161			} else {162				left = parseInt(evt.clientX - 280);163				top = parseInt(evt.clientY - 86);164			}165		} else {166			if (isFullscreen) {167				left = parseInt((evt.x ? evt.x : evt.pageX));168				top = parseInt((evt.y ? evt.y : evt.pageY) + 20);169			} else {170				left = parseInt((evt.x ? evt.x : evt.pageX) - 280);171				top = parseInt((evt.y ? evt.y : evt.pageY) - 86);172			}173		}174		return {175			left: left,176			top: top177		};178	},179	//è·åæç¤º180	getTooltip: function() {181		return jQuery("#gismap .map-measure-tooltip");182	},183	// æ¡é184	rectangleSelect: function(obj) {185		InpectDrawtool.deactivate();186		InspectMarkertool.deactivate();187		InspectMeasuretool.setTool("distance", false);188		GisMapTools.hideTooltip();189		//鿾鼠æ ç§»å¨åç¹å»äºä»¶190		if (MeasureOnMouseMoveHandle) {191			dojo.disconnect(MeasureOnMouseMoveHandle);192		}193		if (MeasureOnClickHandle) {194			dojo.disconnect(MeasureOnClickHandle);195		}196		InspectPager = null;197		var This = jQuery(obj);198		This.parent().parent().fadeOut(200);199		GisMapTools.selectType = "geometry";200		InpectDrawtool.activate(esri.toolbars.Draw.RECTANGLE);201		jQuery("#gismap").bind("mousemove", function(evt) {202			var position = GisMapTools.getTooltipPosition(evt);203			GisMapTools.getTooltip().css({204				left: position.left + "px",205				top: position.top + "px"206			});207			GisMapTools.getTooltip().html("æä½é¼ æ å·¦é®æéåºå,</br>鿾宿ç»å¶ã");208		});209	},210	// åé211	circleSelect: function(obj) {212		InpectDrawtool.deactivate();213		InspectMarkertool.deactivate();214		InspectMeasuretool.setTool("distance", false);215		//鿾鼠æ ç§»å¨åç¹å»äºä»¶216		if (MeasureOnMouseMoveHandle) {217			dojo.disconnect(MeasureOnMouseMoveHandle);218		}219		if (MeasureOnClickHandle) {220			dojo.disconnect(MeasureOnClickHandle);221		}222		GisMapTools.hideTooltip();223		InspectPager = null;224		var This = jQuery(obj);225		This.parent().parent().fadeOut(200);226		GisMapTools.selectType = "geometry";227		InpectDrawtool.activate(esri.toolbars.Draw.CIRCLE);228		jQuery("#gismap").bind("mousemove", function(evt) {229			var position = GisMapTools.getTooltipPosition(evt);230			GisMapTools.getTooltip().css({231				left: position.left + "px",232				top: position.top + "px"233			});234		});235		GisMapTools.getTooltip().html("æä½é¼ æ å·¦é®æéåºå,</br>鿾宿ç»å¶ã");236	},237	// åæ æ°ç»è½¬æ¢238	convertArrayToWKT: function(arr) {239		if (arr === null || arr === '' || arr === 'undefined') {240			return;241		}242		var result = "POLYGON((";243		for (var i = 0, j = arr.length; i < j; i++) {244			if (i === j - 1) {245				result += arr[i][0] + " " + arr[i][1] + "))";246			} else {247				result += arr[i][0] + " " + arr[i][1] + ",";248			}249		}250		return result;251	},252	// éåºååè°å½æ°253	searchCallBack: function(geometry, curr_page, page_size) {254		GisMapTools.currGeometry = geometry;255		InpectDrawtool.deactivate();256		GisMapTools.hideTooltip();257		var points = GisMapTools.convertArrayToWKT(geometry.geographicGeometry.rings[0]);258		jQuery.ajax({259			url: "/service/map/map_geometry_cameras",260			type: 'get',261			cache: false,262			data: {263				points: points,264				current_page: curr_page ? curr_page : 1,265				page_size: page_size ? page_size : 10266			},267			dataType: 'json',268			success: function(res) {269				if (res.code === 200) {270					GisMapTools.setCamerasToMap(res);271				} else if (res.code === 500) {272					notify.error(res.data.message);273				} else {274					notify.error("è·åæ°æ®å¼å¸¸ï¼");275				}276			},277			error: function() {278				notify.error("请æ¥çç½ç»ç¶åµï¼");279			}280		});281	},282	registerHelper: function(){283		Handlebars.registerHelper("cameraStatusAndType", function(status, type,  options){284			if((status===0)&& (type===0)){285				return "camera-gun-online";286			}287			if((status===0)&& (type===1)){288				return "camera-gun-offline";289			}290			if((status===1)&& (type===0)){291				return "camera-ball-online";292			}293			if((status===1)&& (type===1)){294				return "camera-ball-offline";295			}296		});297		//左边æ¾ç¤ºæç´¢ç»æ298		Handlebars.registerHelper("isOnline", function(num, options) {299			if (num === 0) {300				return options.fn({'data':true});301			}302			if (num === 1) {303				return options.fn({'data':false});304			}305			return options.fn();306		});307		Handlebars.registerHelper("picture", function(imgUrl) {308			if (imgUrl) {309				return imgUrl;310			}311			return "/assets/images/map/video-default.png";312		});313	},314	// ç»å°å¾æçæ§ç¹315	setCamerasToMap: function(resultdata) {316		dojo.disconnect(SearchResultLayerGraphicsOnClickHandle);317		dojo.disconnect(SearchResultLayerGraphicsOnMouseoverHandle);318		dojo.disconnect(SearchResultLayerGraphicsOnMouseoutHandle);319		InspectMap.infoWindow.hide();320		if (GisMapTools.searchResultLayer) {321			GisMapTools.searchResultLayer.clear();322		} else {323			GisMapTools.searchResultLayer = new esri.layers.GraphicsLayer({324				id: "search-result-layer"325			});326			InspectMap.addLayer(GisMapTools.searchResultLayer);327		}328		var cameraNum = resultdata.data.cameras.length;329		var cameraSymbol = null;330		var textSymbol = null;331		var cameraFlag = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'];332		for (var i = 0; i < cameraNum; i++) {333			resultdata.data.cameras[i].num = cameraFlag[i];334			var imgSymbolData = resultdata.data.cameras[i];335			var textSymbolData = resultdata.data.cameras[i];336			textSymbolData.index = i * 2 + 1;337			imgSymbolData.index = i * 2;338			cameraSymbol = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-marker-red.png", 22, 26).setOffset(2, 1);339			textSymbol = new esri.symbol.TextSymbol(cameraFlag[i],340				new esri.symbol.Font("12px"),341				new dojo.Color("#fff"));342			//ä¿¡æ¯çªï¼å¾çï¼343			var picture = imgSymbolData.imgUrl ? imgSymbolData.imgUrl : "/assets/images/map/video-default.png";344			var content = Handlebars.compile(jQuery("#map-camera-info").html());345			var infoTemplate = new esri.InfoTemplate({346				title: resultdata.data.cameras[i].name,347				content: content(resultdata.data.cameras[i])348			});349			//çæ§ç¹æ æ³¨350			if (resultdata.data.cameras[i].longitude && resultdata.data.cameras[i].latitude) {351				var webMercator = new esri.geometry.Point(parseFloat(resultdata.data.cameras[i].longitude), parseFloat(resultdata.data.cameras[i].latitude));352				if (mapConfig.coorTransform) {353					webMercator = esri.geometry.geographicToWebMercator(webMercator);354				}355				var marker = new esri.Graphic({356					"geometry": {357						"x": webMercator.x,358						"y": webMercator.y,359						"spatialReference": {360							"wkid": mapConfig.extent.spatialReference.wkid ? mapConfig.extent.spatialReference.wkid : 102100361						}362					},363					"attributes": imgSymbolData364				});365				marker.setSymbol(cameraSymbol);366				marker.setInfoTemplate(infoTemplate);367				GisMapTools.searchResultLayer.add(marker);368				var textMarker = new esri.Graphic({369					"geometry": {370						"x": webMercator.x,371						"y": webMercator.y,372						"spatialReference": {373							"wkid": mapConfig.extent.spatialReference.wkid ? mapConfig.extent.spatialReference.wkid : 102100374						}375					},376					"attributes": textSymbolData377				});378				textMarker.setSymbol(textSymbol);379				textMarker.setInfoTemplate(infoTemplate);380				GisMapTools.searchResultLayer.add(textMarker);381			}382		}383		jQuery(".esriPopup .titleButton.close").unbind("click");384		jQuery(".esriPopup .titleButton.close").click(function() {385			if (GisMapTools.currentCamera) {386				var num = GisMapTools.currentCamera.attributes.num;387				//éç½®æ æ³¨ç徿 388				var hoverCameraSymbol = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-marker-red.png", 22, 26).setOffset(2, 1);389				GisMapTools.currentCamera.setSymbol(hoverCameraSymbol);390				var ThisSearchResult = jQuery(".map-search-result-item[item_id |= '" + num + "']");391				if (ThisSearchResult.hasClass("active")) {392					ThisSearchResult.removeClass("active");393					ThisSearchResult.find(".map-result-ico-red").removeClass("active");394					ThisSearchResult.find(".third-line").removeClass("active");395				}396				GisMapTools.currentCamera = null;397			}398		});399		// é¼ æ åå»çæ§ç¹400		SearchResultLayerGraphicsOnClickHandle = GisMapTools.searchResultLayer.on("mouse-down", function(e) {401			if (e.graphic.attributes) {402				var num = e.graphic.attributes.num;403				var index = e.graphic.attributes.index;404				if (index % 2 === 1) {405					index = index - 1;406				}407				var currGraphic = this.graphics[index];408				if (GisMapTools.currentCamera !== null) {409					var cameraSymbol = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-marker-red.png", 22, 26).setOffset(2, 1);410					GisMapTools.currentCamera.setSymbol(cameraSymbol);411				}412				InspectMap.infoWindow.updateHighlight(InspectMap, currGraphic);413				var hoverCameraSymbol = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-marker-blue.png", 22, 29).setOffset(1, 1);414				currGraphic.setSymbol(hoverCameraSymbol);415				//设置左侧æç´¢ç»æ416				var ThisSearchResult = jQuery(".map-search-result-item[item_id |= '" + num + "']");417				GisMapTools.linkageToSearchResultClick(ThisSearchResult[0]);418				GisMapTools.currentCamera = currGraphic;419				GisMapTools.isOnClickGraphic = true;420			}421		});422		//é¼ æ æ¬æµ®çæ§ç¹423		SearchResultLayerGraphicsOnMouseoverHandle = GisMapTools.searchResultLayer.on("mouse-over", function(e) {424			if (e.graphic.attributes) {425				var num = e.graphic.attributes.num;426				if (GisMapTools.currentCamera) {427					if (GisMapTools.currentCamera.attributes.num === num) {428						return;429					}430				}431				var index = e.graphic.attributes.index;432				if (index % 2 === 1) {433					index = index - 1;434				}435				var currGraphic = this.graphics[index];436				var textGraphic = this.graphics[index + 1];437				var hoverCameraSymbol = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-marker-blue.png", 22, 29).setOffset(1, 1);438				currGraphic.setSymbol(hoverCameraSymbol);439				//设置左侧æç´¢ç»æ440				var ThisSearchResult = jQuery(".map-search-result-item[item_id |= '" + num + "']");441				GisMapTools.linkageToSearchResultHover(ThisSearchResult[0]);442			}443		});444		//é¼ æ ç§»åºçæ§ç¹445		SearchResultLayerGraphicsOnMouseoutHandle = GisMapTools.searchResultLayer.on("mouse-out", function(e) {446			if (e.graphic.attributes) {447				var num = e.graphic.attributes.num;448				if (GisMapTools.currentCamera) {449					if (GisMapTools.currentCamera.attributes.num === num) {450						return;451					}452				}453				var index = e.graphic.attributes.index;454				if (index % 2 === 1) {455					index = index - 1;456				}457				var currGraphic = this.graphics[index];458				var cameraSymbol = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-marker-red.png", 22, 26).setOffset(2, 1);459				currGraphic.setSymbol(cameraSymbol);460				//设置左侧æç´¢ç»æ461				var ThisSearchResult = jQuery(".map-search-result-item[item_id |= '" + num + "']");462				GisMapTools.linkageToSearchResultHoverout(ThisSearchResult[0]);463			}464		});465		466		var pagerListener = null,467			template = Handlebars.compile(jQuery("#map-search-result").html());468		if (InspectPager === null) {469			var templateContainer = Handlebars.compile(jQuery("#map-search-result-container").html());470			jQuery("#camerasPanel .overview > .mapping").empty().html(templateContainer);471		}472		jQuery("#camerasPanel .overview > .mapping #mapSearchResult").empty().html(template(resultdata.data));473		// 忢颿¿474		jQuery('#treePanel .overview').children().hide().filter('.mapping').show();475		jQuery('#treePanel .form-panel').children().removeClass('active');476		GisMapTools.bindSearchResultEvents();477		if (InspectPager === null) {478			if (GisMapTools.selectType === "geometry") {479				pagerListener = GisMapTools.searchCallBack;480			} else if (GisMapTools.selectType === "group") {481				pagerListener = GisMapTools.searchArea;482			}483			InspectPager = new MapPage({484				curr_page: 1,485				page_size: 10,486				target: "map-pager",487				total_page: resultdata.data.count / 10 > parseInt(resultdata.data.count / 10) ? parseInt(resultdata.data.count / 10) + 1 : parseInt(resultdata.data.count / 10),488				listener: pagerListener489			});490		}491	},492	grouplist: function(list, parent) {493		if (jQuery("#groupwrap").length !== 0) {494			jQuery("#groupwrap").remove();495		}496		jQuery.when(Toolkit.loadTempl('/assets/inc/grouplist.html')).done(function(source) {497			var template = Handlebars.compile(source);498			parent.append(template(list));499		});500	},501	//ç»å®æç´¢ç»æäºä»¶502	bindSearchResultEvents: function() {503		//æç´¢ç»æäºä»¶ç»å®504		jQuery(".map-search-result-item").bind({505			click: function() {506				GisMapTools.clickSearchResultItem(this);507			},508			mouseenter: function() {509				GisMapTools.hoverSearchResultItem(this);510			},511			mouseleave: function() {512				GisMapTools.hoveroutSearchResultItem(this);513			}514		});515		//æ·»å å°èªå®ä¹åç»516		jQuery(".map-search-result-item .map-add-group").click(function() {517			var data = jQuery(this).closest(".search-result").data();518			var parent = jQuery(this);519			jQuery.getJSON("/service/video_access/list_customGroup?cameraId=" + data.id + "&r=" + Math.random(), function(res) {520				GisMapTools.grouplist(res.data, parent);521				if (jQuery(".grouplist").has("h2")) {522					return;523				}524				jQuery(".grouplist").tinyscrollbar({525					thumbSize: 15526				});527			});528			e.stopPropagation();529		});530		jQuery(".map-search-result-item .map-add-group").mouseleave(function() {531			jQuery("#groupwrap").hide();532		});533		//æ·»å å°çå·¡åç»534		jQuery(".map-search-result-item .map-add-inspect").click(function() {535			var data = jQuery(this).closest(".search-result").data();536			var parent = jQuery(this);537			VideoWatch.getVideoWatchList(data.id, function(list) {538				GisMapTools.grouplist({539					cameras: list540				}, parent);541				if (jQuery(".grouplist").has("h2")) {542					return;543				}544				jQuery(".grouplist").tinyscrollbar({545					thumbSize: 10546				});547			});548			e.stopPropagation();549		});550		jQuery(".map-search-result-item .map-add-inspect").mouseleave(function() {551			jQuery("#groupwrap").hide();552		});553		//è§é¢ææ¾554		jQuery(".map-search-result-item .map-result-play").click(function(e) {555			var index = jQuery(this).closest(".map-search-result-item").attr("Index");556			GisMapTools.linkageToMapGeometry(index);557			if(jQuery(this).parent().find("span").html() === "(å¨çº¿)"){558				GisMapTools.playMapCameraVideo();559			}else{560				GisMapTools.showMapCameraInfo();561			}562			e.stopPropagation();563		});564		jQuery(".map-search-result-item .map-result-play").mouseleave(function() {565			jQuery("#groupwrap").hide();566		});567		//åå²è°é
568		jQuery(".map-search-result-item .map-result-history").click(function() {569			notify.warn("该åè½ææªå®ç°ï¼");570		});571		jQuery(".map-search-result-item .map-result-history").mouseleave(function() {572			jQuery("#groupwrap").hide();573		});574		//åéå°çµè§å¢575		jQuery(".map-search-result-item .map-result-sendtotvwall").click(function() {576			notify.warn("该åè½ææªå®ç°ï¼");577		});578		jQuery(".map-search-result-item .map-result-sendtotvwall").mouseleave(function() {579			jQuery("#groupwrap").hide();580		});581	},582	//ææ¾å°å¾ä¸çæåæºçè§é¢583	playMapCameraVideo: function(){584		//æ¾ç¤ºä¿¡æ¯çªå£585		InspectMap.infoWindow.setTitle(GisMapTools.currentCamera.getTitle());586		InspectMap.infoWindow.setContent(jQuery("#map-camera-video").html());587		InspectMap.infoWindow.show(GisMapTools.currentCamera.geometry);588		//ææ¾è§é¢589		var videoPlayer = new VideoPlayer({590			layout: 1,591			uiocx: '#UIOCXMAP',592			npsdk: '#COREOCXMAP'593		});594		videoPlayer.openChannelByIndex({595			ip: GisMapTools.currentCamera.attributes.ip,596			port: GisMapTools.currentCamera.attributes.port,597			username: GisMapTools.currentCamera.attributes.username,598			password: GisMapTools.currentCamera.attributes.password,599			path: GisMapTools.currentCamera.attributes.path,600			autoplay: true,601			loop: false,602			status: GisMapTools.currentCamera.attributes.cameraStatus603		}, 0);604	},605	//æ¾ç¤ºå°å¾ä¸æåæºçåºæ¬ä¿¡æ¯606	showMapCameraInfo: function(){607		//æ¾ç¤ºä¿¡æ¯çªå£608		InspectMap.infoWindow.setTitle(GisMapTools.currentCamera.getTitle());609		InspectMap.infoWindow.setContent(GisMapTools.currentCamera.getContent());610		InspectMap.infoWindow.show(GisMapTools.currentCamera.geometry);611		jQuery(".camera-status-online").click(function(){612			GisMapTools.playMapCameraVideo();613		});614	},615	// è§é¢æ©å±616	videoExpand: function() {617	},618	// ç§»å¨çæ§ç¹ä½ç½®619	moveCameraPosition: function() {620	},621	// ç§»é¤çæ§ç¹622	removeCamera: function() {623	},624	// çæ§ç¹è¯¦ç»ä¿¡æ¯625	cameraDetail: function() {626	},627	// å·¡æ£628	inspectVideo: function() {629	},630	// æ¾ç¤ºæ¥è¦ä¿¡æ¯631	showAlarmInfo: function() {632	},633	// æ¾ç¤ºå¨è¾¹æç´¢634	showSearchAround: function(obj) {635		jQuery(".map-region-info").fadeOut(200);636		jQuery(".map-select-list").fadeOut(200);637		// è·ååç»ä¿¡æ¯638		jQuery.ajax({639			url: "/service/map/search_group_info/",640			type: 'get',641			cache: false,642			dataType: 'json',643			success: function(res) {644				if (res.code === 200) {645					var This = jQuery(obj),646						Next = This.next();647					if (Next.is(":hidden")) {648						Next.fadeIn(200);649					} else if (Next.is(":visible")) {650						Next.fadeOut(200);651					}652					// 渲æåç»ä¿¡æ¯653					var template = Handlebars.compile(jQuery("#map-around-search-template").html());654					jQuery("#mapSearchAroundContent").html(template(res.data));655				} else if (res.code === 500) {656					notify.error(res.data.message);657				} else {658					notify.error("è·åæ°æ®å¼å¸¸ï¼");659				}660			},661			error: function() {662				notify.error("请æ¥çç½ç»ç¶åµï¼");663			}664		});665	},666	// æç´¢æä¸ªåºå667	searchArea: function(obj, curr_page, page_size) {668		GisMapTools.selectType = "group";669		GisMapTools.groupObj = obj;670		if ((typeof curr_page === 'undefined') || (typeof page_size === 'undefined')) {671			InspectPager = null;672		}673		var This = jQuery(obj);674		This.parent().parent().parent().fadeOut(200);675		// è°ç¨æ¥å£676		jQuery.ajax({677			url: "/service/map/group_search_result",678			type: 'get',679			cache: false,680			data: {681				groupId: This.attr("groupId"),682				type: This.attr("groupType"),683				current_page: curr_page ? curr_page : 1,684				page_size: page_size ? page_size : 10685			},686			dataType: 'json',687			success: function(res) {688				if (res.code === 200) {689					GisMapTools.setCamerasToMap(res);690				} else if (res.code === 500) {691					notify.error(res.data.message);692				} else {693					notify.error("è·åæ°æ®å¼å¸¸ï¼");694				}695			},696			error: function() {697				notify.error("请æ¥çç½ç»ç¶åµï¼");698			}699		});700	},701	// æµéé¿åº¦702	measurLength: function(obj) {703		InspectMeasuretool.setTool("distance", false);704		InpectDrawtool.deactivate();705		InspectMarkertool.deactivate();706		InspectMap.disableDoubleClickZoom();707		dojo.disconnect(MeasureOnMouseMoveHandle);708		dojo.disconnect(MeasureOnClickHandle);709		var measureTooltip = jQuery("#gismap .map-measure-tooltip")[0];710		measureTooltip.style.left = "-2000px";711		measureTooltip.innerHTML = "åå»ç¡®å®èµ·ç¹";712		var isStartMeasure = false;713		InspectMeasuretool.measureDistance();714		//æµéé¼ æ ç§»å¨äºä»¶715		MeasureOnMouseMoveHandle = dojo.connect(InspectMap, "onMouseMove", InspectMeasuretool, function(evt) {716			var top, left;717			var position = GisMapTools.getTooltipPosition(evt);718			if (isStartMeasure) {719				var result = InspectMeasuretool._geodesicDistance(InspectMeasuretool._currentStartPt, evt.mapPoint);720				if (!(isNaN(result))) {721					measureTooltip.style.top = position.top + "px";722					measureTooltip.style.left = position.left + "px";723					measureTooltip.innerHTML = "æ»é¿ï¼" + parseInt((result + InspectMeasuretool.result) * InspectMeasuretool.unitDictionary['ç±³']) + "ç±³<br>åå»ç¡®å®å°ç¹ï¼åå»ç»æ";724				}725			} else {726				measureTooltip.style.top = position.top + "px";727				measureTooltip.style.left = position.left + "px";728			}729		});730		//æµéé¼ æ ç¹å»äºä»¶731		MeasureOnClickHandle = dojo.connect(InspectMap, "onClick", InspectMeasuretool, function(evt) {732			isStartMeasure = true;733			var point = evt.mapPoint;734			var result = parseInt(InspectMeasuretool.result * InspectMeasuretool.unitDictionary['ç±³']);735			if (result > 0) {736				//设置æç´¢ç»æ737				var textMarker = new esri.Graphic({738					"geometry": {739						"x": point.x,740						"y": point.y,741						"spatialReference": {742							"wkid": mapConfig.extent.spatialReference.wkid ? mapConfig.extent.spatialReference.wkid : 102100743						}744					}745				});746				var resultSymbol = new esri.symbol.TextSymbol(result + "ç±³",747					new esri.symbol.Font("12px"),748					new dojo.Color("#000")).setOffset(10, 10);749				textMarker.setSymbol(resultSymbol);750				InspectMap.graphics.add(textMarker);751				InspectMeasuretool.measureGraphics.push(textMarker);752			} else {753				measureTooltip.innerHTML = "åå»ç¡®å®èµ·ç¹";754			}755		});756	},757	// æªå¾758	mapScreenshot: function(obj) {759		var mbr = Map.param.map.getBoundsLatLng();760	},761	// æå°762	mapPrint: function(obj) {763	},764	// åå§åæ è®°å¨ä½765	initMark: function(obj) {766		InspectMeasuretool.setTool("distance", false);767		GisMapTools.hideTooltip();768		//鿾鼠æ ç§»å¨åç¹å»äºä»¶769		if (MeasureOnMouseMoveHandle) {770			dojo.disconnect(MeasureOnMouseMoveHandle);771		}772		if (MeasureOnClickHandle) {773			dojo.disconnect(MeasureOnClickHandle);774		}775		InpectDrawtool.deactivate();776		InspectMarkertool.activate(esri.toolbars.Draw.POINT);777		jQuery("#gismap").bind("mousemove", function(evt) {778			var position = GisMapTools.getTooltipPosition(evt);779			GisMapTools.getTooltip().css({780				left: position.left + "px",781				top: position.top + "px"782			});783			GisMapTools.getTooltip().html("ç¹å»å·¦é®æ è®°ä½ç½®");784		});785	},786	// ç»ææ è®°å¨ä½787	endMark: function(evt) {788		GisMapTools.markerCount++;789		dojo.disconnect(InspectMap.graphics);790		InspectMarkertool.deactivate();791		InspectMap.enableMapNavigation();792		GisMapTools.hideTooltip();793		var symbol = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-marker.png", 13, 21);794		var markerGraphic = new esri.Graphic(evt.geometry, symbol),795			textGraphic = null;796		InspectMap.graphics.add(markerGraphic);797		//æ¾ç¤ºæ·»å çªå£798		GisMapTools.markerAddWin(evt.geometry);799		//ç»å®ä¿åäºä»¶800		GisMapTools.markerAddSave(evt.geometry, markerGraphic);801		//ç»å®å é¤äºä»¶802		GisMapTools.markerDelete(markerGraphic);803		InspectMap.graphics.on("click", function(evt) {804			if (evt.graphic) {805				if (evt.graphic.attributes) {806					if (evt.graphic.attributes.isBtn) {807						return;808					}809					if (evt.graphic.symbol.type === "picturemarkersymbol" || evt.graphic.symbol.type === "textsymbol") {810						//æ¾ç¤ºæ æ³¨ä¸å¡çªå£811						GisMapTools.markerBusinessWin(evt.graphic.attributes.name, evt.graphic.attributes.remark, evt.graphic.geometry, evt.graphic.attributes.index);812					}813				} else {814					var attributes = {815						name: "",816						remark: "",817						index: GisMapTools.markerCount818					};819					evt.graphic.setAttributes(attributes);820					return;821				}822			}823		});824	},825	markerAddWin: function(geometry) {826		//æ¾ç¤ºä¿¡æ¯çªå£827		InspectMap.infoWindow.setTitle("æ·»å æ è®°");828		InspectMap.infoWindow.setContent(jQuery("#map-mark-add").html());829		InspectMap.infoWindow.show(geometry);830	},831	markerAddSave: function(geometry, markerGraphic) {832		jQuery("#mapId").find("#saveMarker").click(function() {833			var name = jQuery("#mapId").find("#markerName").val();834			var remark = jQuery("#mapId").find("#markerDescription").val();835			var attributes = {836				name: name,837				remark: remark,838				index: GisMapTools.markerCount839			};840			if (name || remark) {841				var textsymbol = new esri.symbol.TextSymbol(name,842					new esri.symbol.Font("12px"),843					new dojo.Color("#000000")).setOffset(18, 12);844				var textGraphic = new esri.Graphic(geometry, textsymbol);845				InspectMap.graphics.add(textGraphic);846				markerGraphic.setAttributes(attributes);847				textGraphic.setAttributes(attributes);848			} else {849				markerGraphic.setAttributes(attributes);850			}851			InspectMap.infoWindow.hide();852			GisMapTools.markerBusinessWin(name, remark, geometry, GisMapTools.markerCount);853		});854	},855	markerEditWin: function(geometry, name, remark) {856		//æ¾ç¤ºä¿¡æ¯çªå£857		InspectMap.infoWindow.setTitle("ç¼è¾æ è®°");858		InspectMap.infoWindow.setContent(jQuery("#map-mark-add").html());859		jQuery("#mapId").find("#markerName").val(name);860		jQuery("#mapId").find("#markerDescription").val(remark);861		InspectMap.infoWindow.show(geometry);862	},863	markerEditSave: function(index, geometry, markerGraphic, textGraphic) {864		jQuery("#mapId").find("#saveMarker").click(function() {865			var name = jQuery("#mapId").find("#markerName").val();866			var remark = jQuery("#mapId").find("#markerDescription").val();867			if (name) {868				var attributes = {869					name: name,870					remark: remark,871					index: index872				};873				if (textGraphic) {874					markerGraphic.setAttributes(attributes);875					textGraphic.symbol.setText(name);876					textGraphic.setSymbol(textGraphic.symbol);877					textGraphic.setAttributes(attributes);878				} else {879					var textsymbol = new esri.symbol.TextSymbol(name,880						new esri.symbol.Font("12px"),881						new dojo.Color("#000000")).setOffset(18, 6);882					textGraphic = new esri.Graphic(geometry, textsymbol);883					textGraphic.setAttributes(attributes);884					InspectMap.graphics.add(textGraphic);885				}886			} else {887				if (textGraphic) {888					InspectMap.graphics.remove(textGraphic);889				}890			}891			InspectMap.infoWindow.hide();892			GisMapTools.markerBusinessWin(name, remark, geometry, index);893		});894	},895	markerDelete: function(markerGraphic, textGraphic) {896		jQuery("#mapId").find("#deleteMarker").click(function() {897			InspectMap.infoWindow.hide();898			InspectMap.graphics.remove(markerGraphic);899			if (textGraphic) {900				InspectMap.graphics.remove(textGraphic);901			}902		});903	},904	markerBusinessWin: function(name, remark, geometry, index) {905		InspectMap.infoWindow.setTitle(name ? name : "æ æ³¨");906		InspectMap.infoWindow.setContent(jQuery("#map-marker-business").html());907		jQuery(".map-marker-business .marker-remark span:first-child").empty().html(remark ? remark : "æç夿³¨");908		var thisMarkerGraphic = null,909			thisTextGraphic = null;910		for (var i = 0, j = InspectMap.graphics.graphics.length; i < j; i++) {911			if (InspectMap.graphics.graphics[i].attributes) {912				if (index === InspectMap.graphics.graphics[i].attributes.index) {913					if (InspectMap.graphics.graphics[i].symbol.type === "picturemarkersymbol") {914						thisMarkerGraphic = InspectMap.graphics.graphics[i];915					}916					if (InspectMap.graphics.graphics[i].symbol.type === "textsymbol") {917						thisTextGraphic = InspectMap.graphics.graphics[i];918						break;919					}920				}921			}922		}923		jQuery(".map-marker-business .marker-remark span.marker-edit").click(function() {924			//æ¾ç¤ºç¼è¾çªå£925			GisMapTools.markerEditWin(geometry, name, remark);926			//ç»å®ä¿åäºä»¶927			GisMapTools.markerEditSave(index, geometry, thisMarkerGraphic, thisTextGraphic);928			//ç»å®å é¤äºä»¶929			GisMapTools.markerDelete(thisMarkerGraphic, thisTextGraphic);930		});931		jQuery("#markerBusinessAll").click(function() {932			GisMapTools.markerAroundMsg(geometry, thisMarkerGraphic, thisTextGraphic);933		});934		jQuery("#markerBusinessCamera").click(function() {935			GisMapTools.markerAroundMsg(geometry, thisMarkerGraphic, thisTextGraphic);936		});937		jQuery("#markerBusinessAlarm").click(function() {938			GisMapTools.markerAroundMsg(geometry, thisMarkerGraphic, thisTextGraphic);939		});940		jQuery("#markerBusinessBayonet").click(function() {941			GisMapTools.markerAroundMsg(geometry, thisMarkerGraphic, thisTextGraphic);942		});943		jQuery("#markerBusinessPolice").click(function() {944			GisMapTools.markerAroundMsg(geometry, thisMarkerGraphic, thisTextGraphic);945		});946		InspectMap.infoWindow.show(geometry);947	},948	markerAroundMsg: function(geometry, MarkerGraphic, TextGraphic) {949		dojo.disconnect(InspectMap.mapMouseDragHandle);950		//åå951		if (GisMapTools.markerCircle) {952			InspectMap.graphics.remove(GisMapTools.markerCircle);953		}954		var outlineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,955			new dojo.Color([172, 185, 209]),956			1);957		var fillSymbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,958			outlineSymbol,959			new dojo.Color([105, 128, 188, 0.2]));960		var circle = new esri.geometry.Circle({961			center: geometry,962			radius: 1000,963			radiusUnit: esri.Units.METERS964		});965		GisMapTools.markerCircle = new esri.Graphic(circle, fillSymbol);966		InspectMap.graphics.add(GisMapTools.markerCircle);967		//ååéç½®å徿é®968		if (GisMapTools.markerCircleResizeBtn) {969			InspectMap.graphics.remove(GisMapTools.markerCircleResizeBtn);970		}971		var pictureMarkerSymbol = new esri.symbol.PictureMarkerSymbol("/assets/images/map/marker-circle-resize.png", 29, 18);972		var pictureMarkerGeometry = new esri.geometry.Point(geometry.x + 1000, geometry.y, geometry.spatialReference);973		GisMapTools.markerCircleResizeBtn = new esri.Graphic(pictureMarkerGeometry, pictureMarkerSymbol);974		GisMapTools.markerCircleResizeBtn.setAttributes({975			"isBtn": true976		});977		InspectMap.graphics.add(GisMapTools.markerCircleResizeBtn);978		//åååå¾æç¤º979		if (GisMapTools.markerCircleRadius) {980			InspectMap.graphics.remove(GisMapTools.markerCircleRadius);981		}982		var radiusMarkerSymbol = new esri.symbol.PictureMarkerSymbol("/assets/images/map/marker-radius.png", 51, 18);983		var radiusMarkerGeometry = new esri.geometry.Point(geometry.x + 1000 + GisMapTools.calculatePx(50), geometry.y, geometry.spatialReference);984		GisMapTools.markerCircleRadius = new esri.Graphic(radiusMarkerGeometry, radiusMarkerSymbol);985		GisMapTools.markerCircleRadius.setAttributes({986			"isBtn": true987		});988		InspectMap.graphics.add(GisMapTools.markerCircleRadius);989		//ååå徿æ¬990		if (GisMapTools.markerCircleRadiusText) {991			InspectMap.graphics.remove(GisMapTools.markerCircleRadiusText);992		}993		var textMarkerSymbol = new esri.symbol.TextSymbol("1000ç±³");994		var textMarkerGeometry = new esri.geometry.Point(geometry.x + 1000 + GisMapTools.calculatePx(50), geometry.y - GisMapTools.calculatePx(5), geometry.spatialReference);995		GisMapTools.markerCircleRadiusText = new esri.Graphic(textMarkerGeometry, textMarkerSymbol);996		GisMapTools.markerCircleRadiusText.setAttributes({997			"isBtn": true998		});999		InspectMap.graphics.add(GisMapTools.markerCircleRadiusText);1000		//æ·»å é¼ æ è½ä¸äºä»¶1001		InspectMap.graphics.on("mouse-down", function(evt) {1002			if (evt.graphic.attributes) {1003				var ie = navigator.userAgent.indexOf("MSIE") > 0;1004				if (evt.graphic.attributes.isBtn) {1005					var moreThenIE9 = function() {1006						var UA = navigator.userAgent,1007							isIE = UA.indexOf('MSIE') > -1,1008							v = isIE ? /\d+/.exec(UA.split(';')[1]) : 'no ie';1009						return v > 9;1010					}();1011					if (ie) {1012						if (!moreThenIE9) {1013							InspectMap.mapMouseDragHandle = InspectMap.on("mouse-drag", function(evt) {1014								GisMapTools.markerRadiusResize(evt, geometry, outlineSymbol, fillSymbol);1015							});1016						} else {1017							InspectMap.mapMouseDragHandle = InspectMap.on("mouse-move", function(evt) {1018								GisMapTools.markerRadiusResize(evt, geometry, outlineSymbol, fillSymbol);1019							});1020						}1021					} else {1022						InspectMap.mapMouseDragHandle = InspectMap.on("mouse-drag", function(evt) {1023							GisMapTools.markerRadiusResize(evt, geometry, outlineSymbol, fillSymbol);1024						});1025					}1026					InspectMap.disablePan();1027				}1028			}1029			InspectMap.markerCenter = geometry;1030		});1031		if (MarkerGraphic) {1032			MarkerGraphic.getDojoShape().moveToFront();1033		}1034		if (TextGraphic) {1035			TextGraphic.getDojoShape().moveToFront();1036		}1037		InspectMap.infoWindow.hide();1038		InspectMap.markerCenter = geometry;1039		InspectMap.markerDragEnd = pictureMarkerGeometry;1040		//æ ¹æ®å ä½å
ç´ éç½®å°å¾å¾å±çº§å«åä¸å¿ç¹1041		GisMapTools.markerCircleReset(geometry, 1000);1042	},1043	//è°æ´åååå¾å¤§å°1044	markerRadiusResize: function(evt, geometry, outlineSymbol, fillSymbol) {1045		var radius = Math.sqrt((evt.mapPoint.x - geometry.x) * (evt.mapPoint.x - geometry.x) + (evt.mapPoint.y - geometry.y) * (evt.mapPoint.y - geometry.y));1046		if (radius > 5000 || radius < 500) {1047			return;1048		}1049		InspectMap.graphics.remove(GisMapTools.markerCircle);1050		var circle = new esri.geometry.Circle({1051			center: geometry,1052			radius: radius,1053			radiusUnit: esri.Units.METERS1054		});1055		GisMapTools.markerCircle = new esri.Graphic(circle, fillSymbol);1056		InspectMap.graphics.add(GisMapTools.markerCircle);1057		if (GisMapTools.markerCircleResizeBtn.getDojoShape()){1058			GisMapTools.markerCircleResizeBtn.getDojoShape().moveToFront();1059		}1060		if (GisMapTools.markerCircleRadius.getDojoShape()){1061			GisMapTools.markerCircleRadius.getDojoShape().moveToFront();1062		}1063		if (GisMapTools.markerCircleRadiusText.getDojoShape()){1064			GisMapTools.markerCircleRadiusText.getDojoShape().moveToFront();1065		}1066		//ä¿®æ¹éç½®ååæé®ä½ç½®1067		var btnGeometry = new esri.geometry.Point(geometry.x + (evt.mapPoint.x - geometry.x), geometry.y, geometry.spatialReference);1068		GisMapTools.markerCircleResizeBtn.setGeometry(btnGeometry);1069		//ä¿®æ¹åååå¾æç¤ºä½ç½®1070		var radiusGeometry = new esri.geometry.Point(geometry.x + (evt.mapPoint.x - geometry.x + GisMapTools.calculatePx(50)), geometry.y, geometry.spatialReference);1071		GisMapTools.markerCircleRadius.setGeometry(radiusGeometry);1072		//ä¿®æ¹ååå徿æ¬1073		var textGeometry = new esri.geometry.Point(geometry.x + (evt.mapPoint.x - geometry.x + GisMapTools.calculatePx(50)), geometry.y - GisMapTools.calculatePx(5), geometry.spatialReference);1074		GisMapTools.markerCircleRadiusText.setGeometry(textGeometry);1075		GisMapTools.markerCircleRadiusText.symbol.setText(parseInt(radius) + "ç±³");1076		GisMapTools.markerCircleReset(geometry, radius);1077		InspectMap.markerDragEnd = evt.mapPoint;1078	},1079	//è®¾ç½®æ æ³¨åéçå¾å±çº§å«1080	markerCircleReset: function(geometry, radius) {1081		var mapHeight = document.getElementById("mapId").offsetHeight,1082			mapWidth = document.getElementById("mapId").offsetWidth;1083		var minLength = mapHeight > mapWidth ? mapWidth : mapHeight;1084		var maxLength = mapHeight > mapWidth ? mapHeight : mapWidth;1085		var scale = radius * 2 / (minLength - 80) * 96 / 0.0254000508;1086		var zoom = InspectMap.getZoom();1087		for (var i = 0, j = mapConfig.lods.length; i < j - 1; i++) {1088			if (scale === mapConfig.lods[i].scale) {1089				zoom = mapConfig.lods[i].level;1090				break;1091			}1092			if (scale < mapConfig.lods[i].scale && scale > mapConfig.lods[i + 1].scale) {1093				zoom = mapConfig.lods[i].level;1094				break;1095			}1096		}1097		InspectMap.centerAndZoom(geometry, zoom);1098		InspectMap.on("zoom-end", function() {1099			InspectMap.reposition();1100		});1101	},1102	calculatePx: function(num) {1103		return InspectMap.getScale() * 0.025400508 / 96 * num;1104	},1105	// å
¨å±1106	fullscreen: function(obj) {1107		var This = jQuery(obj);1108		jQuery("#navigator,#header").hide();1109		jQuery("#sidebar").hide();1110		jQuery("#content .wrapper").css("top", "0px");1111		jQuery("#major").css({1112			top: "0px",1113			left: "0px"1114		});1115		var exitFullscreen = Handlebars.compile(jQuery("#map-exitfullscreen").html());1116		This.parent().empty().html(exitFullscreen);1117		InspectMap.resize();1118	},1119	// éåºå
¨å±1120	exitFullscreen: function(obj) {1121		var This = jQuery(obj);1122		jQuery("#navigator,#header,#sidebar").show();1123		jQuery("#content .wrapper").css("top", "86px");1124		jQuery("#major").css({1125			top: "10px",1126			left: jQuery("#sidebar").width()1127		});1128		var fullscreen = Handlebars.compile(jQuery("#map-fullscreen").html());1129		This.parent().empty().html(fullscreen);1130		InspectMap.resize();1131	},1132	// 忢å¾å±1133	switchMapLayer: function(obj) {1134		var This = jQuery(obj);1135		if (This.attr("layer") === "normal") {1136			This.removeClass("map-layer-satellite").addClass("map-layer-normal");1137			This.attr("layer", "sattilate");1138			This.attr("title", "æ¾ç¤ºå«æå°å¾");1139			This.find(".map-layer-text").text("å°å¾");1140			// å¾å±åæ¢å°å«æå°å¾1141			InspectBaseLayer.hide();1142			InspectSatelliteLayer.show();1143			//é¹°ç¼åæ¢1144			jQuery("#baselayerOverview").css("display", "none");1145			jQuery("#sattilatelayerOverview").show();1146			SattilateLayerOverview.show();1147		} else {1148			This.removeClass("map-layer-normal").addClass("map-layer-satellite");1149			This.attr("layer", "normal");1150			This.attr("title", "æ¾ç¤ºæ®éå°å¾");1151			This.find(".map-layer-text").text("嫿");1152			// å¾å±åæ¢å°æ®éå°å¾1153			InspectSatelliteLayer.hide();1154			InspectBaseLayer.show();1155			//é¹°ç¼åæ¢1156			jQuery("#sattilatelayerOverview").css("display", "none");1157			jQuery("#baselayerOverview").show();1158			BaseLayerOverview.show();1159		}1160	},1161	//ç¹å»æç´¢ç»æèå¨å°å¾å
ç´ 1162	linkageToMapGeometry: function(index){1163		index = parseInt(index);1164		if (GisMapTools.searchResultLayer.graphics) {1165			var currGeometry = GisMapTools.searchResultLayer.graphics[index];1166			if (currGeometry) {1167				//é«äº®éä¸çå
ç´ 1168				var highLight = InspectMap.infoWindow.updateHighlight(InspectMap, currGeometry);1169				InspectMap.infoWindow.showHighlight();1170				var textGeometry = GisMapTools.searchResultLayer.graphics[index + 1];1171				var activeCameraSymbol = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-marker-blue.png", 22, 29).setOffset(1, 1);1172				currGeometry.setSymbol(activeCameraSymbol);1173				if (currGeometry.getDojoShape()) {1174					currGeometry.getDojoShape().moveToFront();1175					textGeometry.getDojoShape().moveToFront();1176				}1177				//è¿å䏿¬¡æ´»å¨ç¹1178				if (GisMapTools.currentCamera !== null && GisMapTools.currentCamera.attributes.index !== index) {1179					var cameraSymbol = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-marker-red.png", 22, 26).setOffset(2, 1);1180					GisMapTools.currentCamera.setSymbol(cameraSymbol);1181				}1182				GisMapTools.currentCamera = currGeometry;1183			} else {1184				notify.warn("è¯¥ç¹æ²¡æå°çåæ ï¼");1185			}1186		}1187	},1188	//å°å¾å
ç´ ç¹å»åèå¨å°æç´¢ç»æ1189	linkageToSearchResultClick: function(obj) {1190		var This = jQuery(obj);1191		var ResultContainer = This.parent();1192		ResultContainer.find(".map-search-result-item").each(function(index) {1193			jQuery(this).data("active", false);1194			jQuery(this).removeClass("active");1195			jQuery(this).find(".third-line").removeClass("active");1196			jQuery(this).find(".map-result-ico-red").removeClass("active");1197		});1198		This.addClass("active");1199		This.find(".third-line").addClass("active");1200		This.find(".map-result-ico-red").addClass("active");1201		This.data("active", true);1202	},1203	// ç¹å»æç´¢ç»æ1204	clickSearchResultItem: function(obj) {1205		var This = jQuery(obj);1206		var ResultContainer = This.parent();1207		ResultContainer.find(".map-search-result-item").each(function(index) {1208			jQuery(this).data("active", false);1209			jQuery(this).removeClass("active");1210			jQuery(this).find(".third-line").removeClass("active");1211			jQuery(this).find(".map-result-ico-red").removeClass("active");1212		});1213		This.addClass("active");1214		This.find(".third-line").addClass("active");1215		This.find(".map-result-ico-red").addClass("active");1216		This.data("active", true);1217		var index = parseInt(This.attr("Index"));1218		GisMapTools.linkageToMapGeometry(index);1219		GisMapTools.showMapCameraInfo();1220	},1221	//å°å¾å
ç´ æ¬æµ®åèå¨å°æç´¢ç»æ1222	linkageToSearchResultHover: function(obj) {1223		var This = jQuery(obj);1224		if (!This.data("active")) {1225			This.addClass("active");1226			This.find(".map-result-ico-red").addClass("active");1227		}1228	},1229	// é¼ æ æ¬æµ®æç´¢ç»æ1230	hoverSearchResultItem: function(obj) {1231		var This = jQuery(obj);1232		if (!This.data("active")) {1233			This.addClass("active");1234			This.find(".map-result-ico-red").addClass("active");1235		}1236		if (GisMapTools.searchResultLayer.graphics) {1237			var index = parseInt(This.attr("Index"));1238			var currGeometry = GisMapTools.searchResultLayer.graphics[index];1239			if (currGeometry) {1240				var textGeometry = GisMapTools.searchResultLayer.graphics[index + 1];1241				if (currGeometry.getDojoShape()) {1242					currGeometry.getDojoShape().moveToFront();1243					textGeometry.getDojoShape().moveToFront();1244				} else {1245					InspectMap.centerAt(currGeometry.geometry);1246				}1247				var activeCameraSymbol = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-marker-blue.png", 22, 29).setOffset(1, 1);1248				currGeometry.setSymbol(activeCameraSymbol);1249			}1250		}1251	},1252	//å°å¾å
ç´ ç§»é¤æ¬æµ®åèå¨å°æç´¢ç»æ1253	linkageToSearchResultHoverout: function(obj) {1254		var This = jQuery(obj);1255		if (!This.data("active")) {1256			This.removeClass("active");1257			This.find(".map-result-ico-red").removeClass("active");1258		}1259	},1260	// é¼ æ ç§»åºæ¬æµ®æç´¢ç»æ1261	hoveroutSearchResultItem: function(obj) {1262		var This = jQuery(obj);1263		if (!This.data("active")) {1264			This.removeClass("active");1265			This.find(".map-result-ico-red").removeClass("active");1266			if (GisMapTools.searchResultLayer.graphics) {1267				var index = parseInt(This.attr("Index"));1268				var currGeometry = GisMapTools.searchResultLayer.graphics[index];1269				if (currGeometry) {1270					var normalCameraSymbol = new esri.symbol.PictureMarkerSymbol("/assets/images/map/map-marker-red.png", 22, 26).setOffset(2, 1);1271					currGeometry.setSymbol(normalCameraSymbol);1272				}1273			}1274		}1275	}...App.js
Source:App.js  
1import './App.css';2import { useState, useEffect } from "react" 3import {Switch, Route, useLocation} from "react-router-dom";4import Navbar from "./Navbar";5import NotificationContainer from "./Notification/NotificationContainer"6import InspectMap from "./InspectMap";7import LoginModal from "./Modal/LoginModal"8import LogoutModal from "./Modal/LogoutModal"9import AppContext from "./Context/AppContext"10import SodaApi from "./helper/SodaApi"11import useLocalStorage from "./hooks/useLocalStorage"12import jwt from "jsonwebtoken"13import config from "./data/config"14function App() {15  const [ restMarker, setRestMarker ] = useState(null);16  const [token, setToken] = useLocalStorage(config.TOKEN_STORAGE_KEY);17  const [currUser, setCurrUser] = useState(null);18  const [notification, setNotification] = useState(false);19  const [notificationType, setNotificationType] = useState(config.INIT_NOTIF_STATE );20  const [ searchMarker, setSearchMarker] = useState(null);21  let location = useLocation();22  let background = location.state && location.state.background;23  useEffect(()=> {24    async function getCurrUser() {25      if (token) {26        try {27          let { username } = jwt.decode(token);28          SodaApi.token = token;29          let currentUser = await SodaApi.getUser(username);30          setCurrUser(currentUser);31        } catch (error) {32          console.error("App getCurrUser Error", error)33          setCurrUser(null)34        }35      };36    };37    getCurrUser()38  }, [token])39  40  useEffect(()=>{41    const timeout = setTimeout(() => {42      setNotificationType(config.INIT_NOTIF_STATE);43      setNotification(false)44    }, 5000);45    return ()=> clearTimeout(timeout)46  },[notification])47  const register = async(formData) => {48    try {49      let token = await SodaApi.register(formData);50      SodaApi.token = token;51      setToken(token);52      return { success: true };53    } catch (errors) {54      console.error("register failed", errors);55      return { success: false, errors};56    }57  };58  const login = async(formData) =>{59    try {60      let token = await SodaApi.login(formData);61      let { username } = jwt.decode(token);62      setToken(token);63      SodaApi.token = token64      return { success: true, username };65    } catch (errors) {66      console.error("Login failed", errors)67      return { success: false, errors};68    }69  }70  const handleShowNotification = (type)=>{71    setNotificationType(type)72    setNotification(true);73  }74 75  const logout = () => {76    setCurrUser(null);77    setToken(null);78  };79  // need to put user Context into userContext80  return (81    <AppContext.Provider value={{register, login, logout, currUser, handleShowNotification, searchMarker, setSearchMarker, restMarker, setRestMarker}}>82      <div className="App">83        <Navbar />84          { notification85              ? <NotificationContainer type={notificationType}/>86              : null}87        <InspectMap />88        <Switch location={ background ||  location }>89        </Switch>90        { background && <Route path="/logout" ><LogoutModal/></Route>}91        { background && <Route path="/registerlogin" ><LoginModal/></Route>}92      </div>93    </AppContext.Provider>94  );95}96export default App;97// import './App.css';98// import {Link, Switch, Route} from "react-router-dom";99// import Navbar from "./Navbar";100// import InspectMap from "./InspectMap";101// function App() {102//   return (103//     <div className="App">104//         <Navbar/>      105//       <Switch>106//         <Route path="/" exact component={InspectMap} />107//       </Switch>108//     </div>109//   );110// }...inspect.js
Source:inspect.js  
...28		})29	);30	return mergeDeep({}, ...inspections);31}32async function inspectMap(map, stack, modelTypes) {33	const [listOfLinks, listOfLink] = partition(values(map), isArray);34	const linksInspections = await Promise.all(35		listOfLinks.map(async links => inspectLinks(links, stack, modelTypes))36	);37	const linkInspections = await Promise.all(38		listOfLink.map(async link => {39			const inspection = await inspectLink(link, stack, modelTypes);40			return { [`... on ${link.type}`]: inspection };41		})42	);43	return {44		_value_: mergeDeep({}, ...linkInspections),45		_list_: mergeDeep({}, ...linksInspections)46	};47}48export async function inspectEntry(type, id, modelTypes, stack = []) {49	try {50		logger.debug(`inspect entry ${type} ${id}`);51		const entryPath = path.resolve(conf.work.content, conf.content.branch, type, id);52		const entryFiles = await fs.readdir(entryPath);53		const entryFields = [54			'_id_',55			...(await Promise.all(56				entryFiles.map(async file => {57					const ext = path.extname(file);58					const key = path.basename(file, ext);59					if (ext === '.json') {60						const contentBuffer = await fs.readFile(path.resolve(entryPath, file));61						const content = JSON.parse(contentBuffer.toString());62						if (content._role_ === 'link') {63							return {64								[key]: await inspectLink(content.link, stack, modelTypes)65							};66						}67						if (content._role_ === 'links') {68							return {69								[key]: await inspectLinks(content.links, stack, modelTypes)70							};71						}72						if (content._role_ === 'map') {73							return {74								[key]: ['_key_', await inspectMap(content.map, stack, modelTypes)]75							};76						}77					}78					return key;79				})80			))81		];82		return entryFields.filter(x => !_.isEmpty(x));83	} catch (error) {84		logger.debug(`Gitasdb inspect error ${error}`);85		return [];86	}87}88export function graphqlQuerySerialize(query) {...Using AI Code Generation
1var fs = require('fs');2var path = require('path');3var Fabric_Client = require('fabric-client');4var Fabric_CA_Client = require('fabric-ca-client');5var util = require('util');6var os = require('os');7var fabric_client = new Fabric_Client();8var fabric_ca_client = null;9var admin_user = null;10var member_user = null;11var store_path = path.join(__dirname, 'hfc-key-store');12console.log('Store path:' + store_path);13var tx_id = null;Using AI Code Generation
1var chai = require('chai');2var expect = chai.expect;3var assert = chai.assert;4var should = chai.should();5var chai = require('chai');6var expect = chai.expect;7var assert = chai.assert;8var should = chai.should();9var chaiMaps = require('chai-maps');10chai.use(chaiMaps);11var map1 = new Map();12map1.set(1, 'a');13map1.set(2, 'b');14map1.set(3, 'c');15var map2 = new Map();16map2.set(1, 'a');17map2.set(2, 'b');18map2.set(3, 'c');19var map3 = new Map();20map3.set(1, 'a');21map3.set(2, 'b');22map3.set(3, 'c');23var map4 = new Map();24map4.set(1, 'a');25map4.set(2, 'b');26map4.set(3, 'c');27var map5 = new Map();28map5.set(1, 'a');29map5.set(2, 'b');30map5.set(3, 'c');31var map6 = new Map();32map6.set(1, 'a');33map6.set(2, 'b');34map6.set(3, 'c');35var map7 = new Map();36map7.set(1, 'a');37map7.set(2, 'b');38map7.set(3, 'c');39var map8 = new Map();40map8.set(1, 'a');41map8.set(2, 'b');42map8.set(3, 'c');43var map9 = new Map();44map9.set(1, 'a');45map9.set(2, 'b');46map9.set(3, 'c');47var map10 = new Map();48map10.set(1, 'a');49map10.set(2, 'b');50map10.set(3, 'c');51var map11 = new Map();52map11.set(1, 'a');53map11.set(2, 'b');54map11.set(3, 'c');55var map12 = new Map();56map12.set(1, 'a');57map12.set(2, 'b');58map12.set(3, 'c');59var map13 = new Map();60map13.set(1, 'Using AI Code Generation
1var chai = require('chai');2var expect = chai.expect;3var inspect = require('util').inspect;4chai.config.includeStack = true;5chai.Assertion.addMethod('inspectMap', function (map) {6  var obj = this._obj;7  new chai.Assertion(obj).to.be.a('Map');8  var actual = obj.get(map);9  var expected = map;10  this.assert(11    'expected #{this} to inspect to #{exp}',12    'expected #{this} to not inspect to #{exp}',13  );14});15var chai = require('chai');16var expect = chai.expect;17var inspect = require('util').inspect;18chai.config.includeStack = true;19describe('Map', function () {20  it('should inspect as a map', function () {21    var myMap = new Map();22    myMap.set('a', 1);Using AI Code Generation
1var Fabric_Client = require('fabric-client');2var path = require('path');3var util = require('util');4var os = require('os');5var fabric_client = new Fabric_Client();6var channel = fabric_client.newChannel('mychannel');7channel.addPeer(peer);8channel.addOrderer(order);9var member_user = null;10var store_path = path.join(__dirname, 'hfc-key-store');11console.log('Store path:'+store_path);12var keyValStore = Fabric_Client.newDefaultKeyValueStore({ path: store_path13});14fabric_client.setStateStore(keyValStore);15var tx_id = null;16var fs = require('fs');17let network_data = fs.readFileSync('../../test-network/organizations/peerOrganizations/org1.example.com/connection-org1.json');18let network_object = JSON.parse(network_data);19let org_mspid = network_object['client']['organization'];20var fabric_ca_client = null;21var fabric_ca_client = new Fabric_Client();22var channel = fabric_ca_client.newChannel('mychannel');23channel.addPeer(peer);24channel.addOrderer(order);25Fabric_Client.newDefaultKeyValueStore({ path: store_path26}).then((state_store) => {27fabric_ca_client.setStateStore(state_store);28var crypto_suite = Fabric_Client.newCryptoSuite();29var crypto_store = Fabric_Client.newCryptoKeyStore({path: store_path});30crypto_suite.setCryptoKeyStore(crypto_store);31fabric_ca_client.setCryptoSuite(crypto_suite);32return fabric_ca_client.getUserContext('admin', true);33}).then((user_from_store) => {34if (user_from_store && user_from_store.isEnrolled()) {35    console.log('Successfully loaded admin fromUsing AI Code Generation
1====');2        return shim.success();3    }4    async Invoke(stub) {5        let ret = stub.getFunctionAndParameters();6        console.info(ret);7        let method = this[ret.fcn];8        if (!method) {9            console.error('no function of name:' + ret.fcn + ' found');10            throw new Error('Received unknown function ' + ret.fcn + ' invocation');11        }12        try {13            let payload = await method(stub, ret.params);14            console.log('payload', payload);15            return shim.success(payload);16        } catch (err) {17            console.log('err', err);18            return shim.error(err);19        }20    }21    async inspectMap(stub, args) {22        let key = args[0];23        let map = new Map();24        map.set('key1', 'value1');25        map.set('key2', 'value2');26        map.set('key3', 'value3');27        map.set('key4', 'value4');28        map.set('key5', 'value5');29        map.set('key6', 'value6');30        map.set('key7', 'value7');31        map.set('key8', 'value8');32        map.set('key9', 'value9');33        map.set('key10', 'value10');34        map.set('key11', 'value11');35        map.set('key12', 'value12');36        map.set('key13', 'value13');37        map.set('key14', 'value14');38        map.set('key15',Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
