123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
- <title>上海城地API</title>
- <style>
- html,
- body,
- #mapDiv {
- padding: 0;
- margin: 0;
- height: 100%;
- width: 100%;
- }
- /*自定义窗口样式*/
- .leaflet-popup-content-wrapper {
- background-color: rgba(0, 0, 0, 0.5) !important;
- color: white !important;
- }
- .leaflet-popup-tip {
- background-color: rgba(0, 0, 0, 0.5) !important;
- }
- .esri-view-surface--inset-outline:focus::after {
- outline: none !important;
- }
- .esri-view-root{
- background-color:#002a4d !important;
- background-size :anto 100%;
- background-position:center;
- }
- canvas{
- //background-color:#002a4d !important;
- }
- </style>
- <script src="js/echarts.min.js"></script>
- <script src="jquery/jquery-2.2.3.min.js"></script>
- <script type="text/javascript" src="jquery/xml2json.js"></script>
- <script>
- var dojoConfig = {
- async: true,
- parseOnLoad: true,
- packages: [{
- name: "lib",
- location: location.pathname.replace(/\/[^/]+$/, "") + "/lib"
- }]
- };
- </script>
- <script src="Common/mapClass/corrugatedPoint/gl-matrix.js"></script>
- <script src="https://10.101.35.50/arcgis_js_api/library/4.19.1/init.js"></script>
- <link rel="stylesheet" href="https://10.101.35.50/arcgis_js_api/library/4.19.1/esri/themes/light/main.css">
- <link rel="stylesheet" href="css/echartsLayerCss.css">
- <!--系统自定义JS-->
- <script src="Common/dataClass/XMLUtil.js"></script> <!--XML操作功能-->
- <script src="Common/dataClass/ConfigManagertest1.js"></script>
- <script src="Common/dataClass/DataCommonClass.js"></script>
- <script src="Common/dataClass/MD5.js"></script>
- <script src="Common/dataClass/Base64.js"></script>
- <script src="Common/mapClass/MapClass420.js"></script>
- <script src="Common/WsCommonClass.js"></script>
- <script src="Common/mapClass/GSFunction.js"></script>
- <script src="Common/mapClass/corrugatedPoint/corrugatedPoint.js"></script>
- <script>
- //监听message
- window.onmessage = function (e) {
- //alert(e.origin);
- //if (e.origin !== 'http://10.101.35.46/WJGisShare/')
- //return;
- var payload;
- try {
- payload = JSON.parse(e.data);
- }
- catch (e) {
- return;
- }
- switch (payload.method) {
- case 'ZoomIn':
- //localStorage.setItem(payload.key, JSON.stringify(payload.data));
- ZoomIn(payload.data);
- break;
- case "ChangerExtent":
- ChangerExtent(payload.data[0], payload.data[1],payload.data[2], payload.data[3]);
- break;
- case 'ZoomOut':
- ZoomOut(payload.data);
- break;
- case 'Clear':
- Clear(payload.data);
- break;
- case 'ViewChange':
- ViewChange();
- break;
- case 'fullExtent':
- toFullExtent();
- break;
- case 'doSetExtent':
- doSetExtent(parseInt(payload.data));
- break;
- case 'measureSquare':
- measureSquare();
- break;
- case 'measureLength':
- measureLength();
- break;
- case 'downLoadPicture':
- downLoadPicture();
- break;
- case 'doGetGraphicByJson':
- doGetGraphicByJson(payload.data[0], payload.data[1]);
- break;
- case 'drawSquare':
- drawSquare();
- break;
- case 'query':
- query(payload.data[0], payload.data[1]);
- break;
- case 'queryByWhereStr':
- querybyWhereStr(payload.data[0], payload.data[1]);
- break;
- case 'openFeatureLayer':
- OpenFeatureLayerByID(payload.data[0], payload.data[1]);
- break;
- case 'openFeatureLayerByName':
- // var isVisible=true;
- // if(parseInt(payload.data[1])==0)
- // {
- // isVisible=false;
- // }
- OpenMapImageLayerByName(payload.data[0], payload.data[1], payload.data[2]);
- break;
- case "GoToJZ":
- {
- queryNoFFXYPointJCZ(payload.data[0], payload.data[1], payload.data[2]);
- break;
- }
- case "ShowBuildlayer":{
- ShowBuildlayer(payload.data[0]);
- break;
- }
- case "switch2Dor3DMap":{
- if (payload.data[0] == "3D") {
- switchTo3DMap();
- }
- else {
- switchTo2DMap();
- }
- break;
- }
- case "ShowBuildlayerSX":{
- ShowBuildlayerSX(payload.data[0]);
- break;
- }
- case "ResettingMap":{
- ResettingMap();
- break;
- }
- case "consoleXYZ":{
- consoleXYZ();
- break;
- }
- case "CloseChangeLayer":
- {
- closeMapImageLayerByName();
- break;
- }
- case 'openFeatureLayer0':
- var isVisible = true;
- if (parseInt(payload.data[0]) == 0) {
- isVisible = false;
- }
- OpenFeatureLayerByID1(0, isVisible);
- break;
- case 'openFeatureLayer1':
- var isVisible = true;
- if (parseInt(payload.data[0]) == 0) {
- isVisible = false;
- }
- OpenFeatureLayerByID1(1, isVisible);
- break;
- case 'openFeatureLayer2':
- var isVisible = true;
- if (parseInt(payload.data[0]) == 0) {
- isVisible = false;
- }
- OpenFeatureLayerByID1(2, isVisible);
- break;
- case 'openFeatureLayer3':
- var isVisible = true;
- if (parseInt(payload.data[0]) == 0) {
- isVisible = false;
- }
- OpenFeatureLayerByID1(3, isVisible);
- break;
- case 'openFeatureLayer4':
- var isVisible = true;
- if (parseInt(payload.data[0]) == 0) {
- isVisible = false;
- }
- OpenFeatureLayerByID1(4, isVisible);
- break;
- case 'openFeatureLayer5':
- var isVisible = true;
- if (parseInt(payload.data[0]) == 0) {
- isVisible = false;
- }
- OpenFeatureLayerByID1(5, isVisible);
- break;
- case 'openFeatureLayer6':
- var isVisible = true;
- if (parseInt(payload.data[0]) == 0) {
- isVisible = false;
- }
- OpenFeatureLayerByID1(6, isVisible);
- break;
- case 'openFeatureLayer7':
- var isVisible = true;
- if (parseInt(payload.data[0]) == 0) {
- isVisible = false;
- }
- OpenFeatureLayerByID1(7, isVisible);
- break;
- case 'openFeatureLayer8':
- var isVisible = true;
- if (parseInt(payload.data[0]) == 0) {
- isVisible = false;
- }
- OpenFeatureLayerByID1(8, isVisible);
- break;
- case 'openFeatureLayer9':
- var isVisible = true;
- if (parseInt(payload.data[0]) == 0) {
- isVisible = false;
- }
- OpenFeatureLayerByID1(9, isVisible);
- break;
- case 'openFeatureLayer10':
- var isVisible = true;
- if (parseInt(payload.data[0]) == 0) {
- isVisible = false;
- }
- OpenFeatureLayerByID1(10, isVisible);
- break;
- case 'setCenterExtent':
- setCenterExtent(payload.data[0], payload.data[1], payload.data[2]);
- break;
- case 'drawCircle':
- {
- drawCircle(payload.data[0]);
- break;
- }
- case 'queryByCircle':
- {
- queryByCircle(payload.data[0], payload.data[1], payload.data[2], payload.data[3])
- break;
- }
- case 'doFlashStatus':
- {
- var flahLayerName = payload.data[0];
- switch (flahLayerName) {
- case "违章建筑":
- flashLayerStatus(fe0, "状态", 1);
- break;
- case "电梯":
- flashLayerStatus(fe4, "状态", 1);
- break;
- case "虹口烟感":
- flashLayerStatus(fe1, "状态", 1);
- break;
- case "摄像头":
- flashLayerStatus(fe2, "状态", 1);
- break;
- case "危险源":
- flashLayerStatus(fe3, "状态", 1);
- break;
- case "门磁":
- flashLayerStatus(fe5, "状态", 1);
- break;
- default:
- ClearLightLayerStatus();
- break;
- }
- break;
- }
- case "onLocation":
- {
- setPointBylonlat(payload.data[0], payload.data[1], payload.data[2], payload.data[3], payload.data[4], payload.data[5], payload.data[6]);
- break;
- }
- case "MeasureLengthByPoint":
- {
- //parent.eval(payload.backfun+"()");
- MeasureLengthByPoint(payload.data[0], payload.data[1], payload.data[2], payload.data[3], payload.backfun);
- break;
- }
- case "newQuery":
- {
- newQuerybyWhereStr(payload.data[0], payload.data[1], GetConfigDataByName("MYQueryLayer"), null, null, payload.data[2]);
- break;
- }
- case "onLocationforGrid" :
- {
- setPointBylonlatForGrid(payload.data[0], payload.data[1]);
- break;
- }
- case "onLocationforAddress":
- {
- setPointBylonlatForAddress(payload.data[0], payload.data[1]);
- break;
- }
- case "onQueryByPoint":
- {
- setPointBylonlatForGetBuffer(payload.data[0], payload.data[1], payload.data[2], payload.data[3], payload.data[4], payload.data[5]);
- break;
- }
- case "onQueryByGrid":
- {
- getGridGeometry(payload.data[0], payload.data[1]);
- break;
- }
- case "onMapCenter":
- {
- var mapcenter = m_view.center;
- window.parent.postMessage(
- {
- method: "mapCenterCallback",
- data: [JSON.stringify(mapcenter).replace(/\"/g, '"')]
- },
- '*'
- );
- break;
- }
- case "onMapLevel":
- {
- var mapzoom = m_view.zoom;
- window.parent.postMessage(
- {
- method: "mapLevelCallback",
- data: [JSON.stringify(mapzoom).replace(/\"/g, '"')]
- },
- '*'
- );
- break;
- }
- case "onMapSetCenter":
- {
- goToZoom(payload.data[0], payload.data[1]);
- // setPointBylonlatForSetCenter(payload.data[0],payload.data[1]);
- break;
- }
- case "onMapSetCenter3D":
- {
- goToZoom3D(payload.data[0], payload.data[1], payload.data[2], payload.data[3], payload.data[4]);
- break;
- }
- case "HeatMap":{
- HeatMap(payload.data[0]);
- break;
- }
- case "onGetXYbyAddress":
- {
- getXYbyAddress(payload.data[0]);
- break;
- }
- case "onSetInitExtentByStr":
- {
- // getXYbyAddress(payload.data[0]);
- if (payload.data[0] == "区县边界")
- queryForExtent(payload.data[0], "区县名称=" + "'" + payload.data[1] + "'", 100);
- else
- queryForExtent(payload.data[0], "街道名称=" + "'" + payload.data[1] + "'", 100);
- break;
- }
- case "onQueryByCondition":
- {
- newQuerybyWhereStr(payload.data[0], payload.data[1], GetConfigDataByName("MYQueryLayer"), null, payload.data[2], payload.data[3]);
- break;
- }
- case "openFeatureLayerByNameandWhere":
- {
- newOpenFeatureLayer(payload.data[0], payload.data[1], payload.data[2], payload.data[3], payload.data[4]);
- break;
- }
- case "onClickLocation":
- {
- m_mapClickdraw = true;
- m_mapAttribute = payload.data[0];
- m_mapToolTip = payload.data[1];
- m_mapImgUrl = payload.data[2];
- m_mapImgWidth = payload.data[3];
- m_mapImgHeight = payload.data[4];
- break;
- }
- case "onSetResizeType":
- {
- sj_type = payload.data[0];
- sj_radius = payload.data[1];
- sj_layername = payload.data[2];
- break;
- }
- case "onSetLayerCluster":
- {
- setLayerCluster(payload.data[0], payload.data[1]);
- break;
- }
- case "doClusterByJson":{
- clusterByJson(payload.data[0],payload.data[1]);
- break;
- }
- case "onShowPolygonandText":
- {
- var jsonarr = payload.data[0];
- for (var i = 0; i < jsonarr.length; i++) {
- var jsonStr = jsonarr[i];
- // var test = jsonStr;
- ShowPolygonandText(jsonStr.type, jsonStr.name, jsonStr.text);
- }
- // ShowPolygonandText(payload.data[0],payload.data[1],payload.data[2]);
- break;
- }
- case "onLocationGetLatLon":
- {
- var action = m_drawtool.create("point");
- require(["esri/geometry/Point", "esri/Graphic"],
- function (Point, Graphic) {
- action.on("draw-complete",
- function (evt) {
- m_view.graphics.removeAll();
- GraphicsLayer_flyTipLayer.removeAll();
- var point = new Point({
- x: evt.coordinates[0],
- y: evt.coordinates[1],
- spatialReference: m_view.spatialReference
- });
- var markerSymbol = {
- type: "simple-marker",
- color: payload.data[0],
- style: "circle",
- size: 10
- }
- var pointGraphic = new Graphic({
- geometry: point,
- symbol: markerSymbol
- });
- GraphicsLayer_flyTipLayer.add(pointGraphic);
- window.parent.postMessage(
- {
- method: "onLocationGetLatLonbackfun",
- data: [evt.coordinates]
- },
- '*'
- );
- });
- });
- break;
- }
- case "onDrawPolygonCircle":
- {
- require(["esri/geometry/Polygon", "esri/Graphic", "esri/geometry/Point", "esri/geometry/Circle"],
- function (Polygon, Graphic, Point, Circle) {
- m_view.graphics.removeAll();
- GraphicsLayer_flyTipLayer.removeAll();
- var action = m_drawtool.create("circle");
- // 获取焦点
- m_view.focus();
- //顶点移除事件
- action.on("vertex-remove", createCircle);
- // 鼠标移动事件
- action.on("cursor-update", createCircle);
- // 绘制完成事件
- action.on("draw-complete", createCirclecomplete);
- function createCircle(event) {
- //获取所有顶点
- var vertices = event.vertices;
- //少于一个点无法展示圆
- if (vertices.length < 2) {
- return
- }
- //清除之前绘制
- GraphicsLayer_flyTipLayer.removeAll();
- //生成绘制的图形,两点画圆
- var center = new Point({
- hasZ: false,
- hasM: false,
- x: vertices[0][0],
- y: vertices[0][1],
- spatialReference: m_view.spatialReference
- });
- var dis = center.distance(new Point({
- hasZ: false,
- hasM: false,
- x: vertices[1][0],
- y: vertices[1][1],
- spatialReference: m_view.spatialReference
- }));
- var graphic = new Graphic({
- geometry: new Circle({
- hasZ: false,
- hasM: false,
- center: center,
- radius: dis,
- spatialReference: m_view.spatialReference
- }),
- symbol: {
- type: "simple-fill", // autocasts as new SimpleFillSymbol()
- color: [51, 51, 204, 0.9],
- style: "solid",
- outline: { // autocasts as new SimpleLineSymbol()
- color: "white",
- width: 1
- }
- }
- });
- // 将绘制的图形添加到view
- GraphicsLayer_flyTipLayer.add(graphic);
- }
- function createCirclecomplete(event) {
- //获取所有顶点
- var vertices = event.vertices;
- //少于一个点无法展示圆
- if (vertices.length < 2) {
- return
- }
- //清除之前绘制
- GraphicsLayer_flyTipLayer.removeAll();
- //生成绘制的图形,两点画圆
- var center = new Point({
- hasZ: false,
- hasM: false,
- x: vertices[0][0],
- y: vertices[0][1],
- spatialReference: m_view.spatialReference
- });
- var dis = center.distance(new Point({
- hasZ: false,
- hasM: false,
- x: vertices[1][0],
- y: vertices[1][1],
- spatialReference: m_view.spatialReference
- }));
- var graphic = new Graphic({
- geometry: new Circle({
- hasZ: false,
- hasM: false,
- center: center,
- radius: dis,
- spatialReference: m_view.spatialReference
- }),
- symbol: {
- type: "simple-fill", // autocasts as new SimpleFillSymbol()
- color: [51, 51, 204, 0.9],
- style: "solid",
- outline: { // autocasts as new SimpleLineSymbol()
- color: "white",
- width: 1
- }
- }
- });
- // 将绘制的图形添加到view
- GraphicsLayer_flyTipLayer.add(graphic);
- window.parent.postMessage(
- {
- method: "onDrawPolygoncallbackfun",
- data: [graphic.geometry.rings]
- },
- '*'
- );
- }
- });
- break;
- }
- case "onLightArea":
- {
- highLightArea(payload.data[0], payload.data[1], payload.data[2], payload.data[3]);
- break;
- }
- case "onEchartsRoute":
- {
- echartsRoute(payload.data[0], payload.data[1], payload.data[2], payload.data[3]);
- break;
- }
- case "onPopupIn":
- {
-
- if (popupInfos.length > 0) {
- popupShowAll();
- }
- else {
- popupInit(payload.data[0], payload.data[1]);
- }
- break;
- }
- case "onPopupClose":
- {
- popupCloseAll();
- popupInfos = [];
- break;
- }
- case 'doDeletePointById':
- doDeletePointById(payload.data[0]);
- break;
- case "doShowAreaName":
- doShowAreaName(payload.data[0], payload.data[1], payload.data[2], payload.data[3], payload.data[4]);
- break;
- case "onDrawPolygonSquare":
- {
- require(["esri/geometry/Polygon", "esri/Graphic", "esri/geometry/Point", "esri/geometry/Circle"],
- function (Polygon, Graphic, Point, Circle) {
- m_view.graphics.removeAll();
- GraphicsLayer_flyTipLayer.removeAll();
- var action = m_drawtool.create("rectangle", {
- mode: "click"//点击方式加点
- });
- // 获取焦点
- m_view.focus();
- //顶点移除事件
- action.on("vertex-remove", createRectangle);
- // 鼠标移动事件
- action.on("cursor-update", createRectangle);
- // 绘制完成事件
- action.on("draw-complete", createRectangleComplete);
- function createRectangle(event) {
- //获取所有顶点
- var vertices = event.vertices;
- //两点画矩形
- if (vertices.length < 2) {
- return
- }
- var rings = [vertices[0], [vertices[0][0], vertices[1][1]], vertices[1], [vertices[1][0], vertices[0][1]]];
- //清除之前绘制
- GraphicsLayer_flyTipLayer.removeAll();
- // 生成绘制的图形
- var graphic = new Graphic({
- geometry: new Polygon({
- hasZ: false,
- hasM: false,
- rings: [rings],
- spatialReference: m_view.spatialReference
- }),
- symbol: {
- type: "simple-fill", // autocasts as new SimpleFillSymbol()
- color: [51, 51, 204, 0.9],
- style: "solid",
- outline: { // autocasts as new SimpleLineSymbol()
- color: "white",
- width: 1
- }
- }
- });
- // 将绘制的图形添加到view
- GraphicsLayer_flyTipLayer.add(graphic);
- }
- function createRectangleComplete(event) {
- //获取所有顶点
- var vertices = event.vertices;
- //两点画矩形
- if (vertices.length < 2) {
- return
- }
- var rings = [vertices[0], [vertices[0][0], vertices[1][1]], vertices[1], [vertices[1][0], vertices[0][1]]];
- //清除之前绘制
- GraphicsLayer_flyTipLayer.removeAll();
- // 生成绘制的图形
- var graphic = new Graphic({
- geometry: new Polygon({
- hasZ: false,
- hasM: false,
- rings: [rings],
- spatialReference: m_view.spatialReference
- }),
- symbol: {
- type: "simple-fill", // autocasts as new SimpleFillSymbol()
- color: [51, 51, 204, 0.9],
- style: "solid",
- outline: { // autocasts as new SimpleLineSymbol()
- color: "white",
- width: 1
- }
- }
- });
- // 将绘制的图形添加到view
- GraphicsLayer_flyTipLayer.add(graphic);
- window.parent.postMessage(
- {
- method: "onDrawPolygoncallbackfun",
- data: [graphic.geometry.rings]
- },
- '*'
- );
- }
- });
- break;
- }
- case "doCorrugatedPointByOid":
- {
- doCorrugatedPointByOid(payload.data[0]);
- break;
- }
- case "doClearCorrugatedPoint":
- {
- doClearCorrugatedPoint();
- break;
- }
- case "doXyToStreetId":
- {
- doXyToStreetId(payload.data[0], payload.data[1]);
- break;
- }
- case "goToGraphic":{
- goToGraphic(payload.data[0], payload.data[1]);
- break;
- }
- case "doWaterRouteClick":
- {
- if (chartLayer) {
- chartLayer.removeLayer();
- chartLayer = null;
- }
- if (chartLayer2) {
- chartLayer2.removeLayer();
- chartLayer2 = null;
- }
- if (chartLayer3) {
- chartLayer3.removeLayer();
- chartLayer3 = null;
- }
- queryResetNumByType(payload.data[0]);
- break
- }
- }
- };
- //初始化配置文件
- GetConfigData();
- require(["dojo/domReady!"], function () {
- loadMap();
- });
- function loadMap() {
- //判断
- initMap();
-
- }
- function onMapLoadInfo() {
- console.log("test2")
- postToParentPageMethed("maploadCallback", []);
- }
- function onMapLoaded() {
- //removeLoadingDiv();
- // GetLayerMainRestInfo2(GetConfigDataByName("MYQueryLayer"));
- // var test = GetConfigDataByName("MYCXFeatureLayerLayer");
- // setPointBylonlat(121,30);
- //alert("加载完成");
- }
- //--------------- 按钮事件 -----------------
- //切换二三维地图
- function onViewTestClick() {
- ViewChange()
- }
- function ViewChange() {
- // m_view.container = null;
- // showLoadingDiv("正在切换地图,请稍后...");
- if (currentMapMode == "2D") {
- switchTo3DMap();
- }
- else {
- switchTo2DMap();
- }
- }
- //清空地图
- function btClear_Click() {
- //Clear();
- }
- function Clear(type) {
- require(["esri/layers/GraphicsLayer"],
- function ( GraphicsLayer) {
- switch (type) {
- case "all":
- {
- m_map.remove(GraphicsLayer_DrawLayer)
- GraphicsLayer_DrawLayer = new GraphicsLayer({id: "myDrawGLayer"});
- GraphicsLayer_DrawLayer.listMode = "hide";
- m_map.remove(m_map.findLayerById("clusterByJsonLayer"));
- m_map.add(GraphicsLayer_DrawLayer);
- GraphicsLayer_myLayer.removeAll();
- isInLightArea = ""
- // GraphicsLayer_DrawLayer.removeAll();
- GraphicsLayer_flyTipLayer.removeAll();
- if (chartLayer) {
- chartLayer.removeLayer();
- chartLayer = null;
- }
- if (chartLayer2) {
- chartLayer2.removeLayer();
- chartLayer2 = null;
- }
- if (chartLayer3) {
- chartLayer3.removeLayer();
- chartLayer3 = null;
- }
- xmlQueryExtend = null;
- queryExtent = null;
- break;
- }
- case "drawLayer":
- {
- GraphicsLayer_DrawLayer.removeAll();
- GraphicsLayer_flyTipLayer.removeAll();
- xmlQueryExtend = null;
- queryExtent = null;
- break;
- }
- case "queryLayer":
- {
- GraphicsLayer_myLayer.removeAll();
- isInLightArea = ""
- GraphicsLayer_flyTipLayer.removeAll();
- xmlQueryExtend = null;
- queryExtent = null;
- break;
- }
- case "chartLayer":
- {
- if (chartLayer) {
- chartLayer.removeLayer();
- chartLayer = null;
- }
- if (chartLayer2) {
- chartLayer2.removeLayer();
- chartLayer2 = null;
- }
- if (chartLayer3) {
- chartLayer3.removeLayer();
- chartLayer3 = null;
- }
- break;
- }
- }
- })
- // var mtype = type | "all";
- }
- //查询
- function btSearch_Click() {
- // var dynamicLayerURL="https://services8.arcgis.com/wUIATpkD1eTGk5lC/arcgis/rest/services/CMRQTest2_WFL1/FeatureServer";
- // var QueryLayerID="13";
- var dynamicLayerURL = "http://139.196.105.31:6080/ArcGIS/rest/services/HKEMAP/MapServer";
- if (GetConfigDataByName("QueryLayer")) {
- dynamicLayerURL = GetConfigDataByName("QueryLayer");
- }
- var QueryLayerID = "13";
- var whereString = "";
- whereString = "HANDLE号 like '%" + document.getElementById("txtSearch").value + "%'";
- require([
- "esri/Graphic",
- "esri/tasks/QueryTask",
- "esri/tasks/support/Query",
- "esri/symbols/SimpleMarkerSymbol",
- "esri/symbols/SimpleLineSymbol",
- "esri/geometry/Point",
- "esri/geometry/Polyline",
- "esri/symbols/PointSymbol3D",
- "esri/renderers/SimpleRenderer",
- "esri/symbols/ObjectSymbol3DLayer",
- "esri/PopupTemplate",
- "dojo/_base/array"
- ], function (Graphic, QueryTask, Query, SimpleMarkerSymbol, SimpleLineSymbol, Point, Polyline, PointSymbol3D, SimpleRenderer, ObjectSymbol3DLayer, PopupTemplate, array) {
- var layerinfo = getLayerByLayerId(QueryLayerID);
- var queryTask = new QueryTask(dynamicLayerURL + "/" + QueryLayerID);
- var query = new Query();
- query.returnGeometry = true;
- query.outFields = ["*"];
- query.where = whereString;
- var defaultPointSymbol = new SimpleMarkerSymbol({
- color: [226, 119, 40],
- outline: { // autocasts as new SimpleLineSymbol()
- color: [255, 255, 255],
- width: 2
- }
- });
- var defaultLineSymbol = new SimpleLineSymbol({
- color: [255, 0, 255],
- width: 2
- });
- var objectSymbol = new PointSymbol3D({
- symbolLayers: [new ObjectSymbol3DLayer({
- width: 2,
- height: 3,
- resource: {
- primitive: "cone"
- },
- material: {
- color: "#FFD700"
- }
- })]
- });
- var objectSymbolRenderer = new SimpleRenderer({
- symbol: objectSymbol
- });
- //graphicsLayer.renderer = objectSymbolRenderer;
- queryTask.execute(query).then(function (results) {
- array.forEach(results.features, function (graphic, i) {
- var graphic2;
- var point2;
- switch (graphic.geometry.type) {
- case "point":
- {
- graphic.geometry.z = 1000;
- graphic.symbol = defaultPointSymbol;
- break;
- }
- case "polyline":
- var geo = Polyline(graphic.geometry);
- geo.hasZ = true;
- geo.hasM = false;
- var paths = geo.paths;
- for (var i = 0; i < paths.length; i++) {
- for (var j = 0; j < paths[i].length; j++) {
- paths[i][j] = [paths[i][j][0], paths[i][j][1], 50];
- }
- var middleNumber = Math.floor(paths[i].length / 2);
- point2 = new Point({
- x: paths[i][middleNumber][0],
- y: paths[i][middleNumber][1],
- z: 50,
- spatialReference: view.spatialReference
- });
- }
- graphic.symbol = defaultLineSymbol;
- graphic.geometry = geo;
- graphic2 = new Graphic();
- graphic2.attributes = graphic.attributes;
- graphic2.geometry = point2;
- graphic2.symbol = objectSymbol;
- graphic2.attributes = graphic.attributes;
- graphic2.popupTemplate = layerinfo.popupTemplate;
- graphic.popupTemplate = new PopupTemplate({
- title: "HANDLE号:{HANDLE号}"
- });
- break;
- }
- GraphicsLayer_myLayer.add(graphic);
- GraphicsLayer_myLayer.add(graphic2);
- });
- });
- })
- }
- var laylistshow = 0;
- function layerOnOff() {
- if (laylistshow == 0) {
- laylistshow = 1;
- m_view.ui.add(layerList, {
- position: "bottom-right"
- });
- }
- else {
- laylistshow = 0;
- m_view.ui.remove(layerList);
- }
- }
- function doSetExtent(num) {
- var xmin, ymin, xmax, ymax;
- switch (num) {
- case 1:
- xmin = -17221.816;
- ymin = -5450.66;
- xmax = -15189.445;
- ymax = -4297.402;
- break;
- case 2:
- xmin = -25930.782;
- ymin = -10527.042;
- xmax = -5599.259;
- ymax = 647.995;
- break;
- case 3:
- xmin = -89836.648;
- ymin = -56485.216;
- xmax = 70797.201;
- ymax = 31738.557;
- break;
- }
- setExtent(xmin, ymin, xmax, ymax);
- }
- var myAttribute, myToolTip, myImgUrl, myImgWidth, myImgHeight;
- function setPointBylonlat(x, y, Attribute, ToolTip, ImgUrl, ImgWidth, ImgHeight) {
- myAttribute = Attribute;
- myToolTip = ToolTip;
- myImgUrl = ImgUrl;
- myImgWidth = ImgWidth;
- myImgHeight = ImgHeight
- var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
- WsCommonClass("ConvertLonLatToXY", ["lon", "lat"], [x, y], getXYbylonlat, null, url);
- }
- function getXYbylonlat(evt) {
- if (evt[0] == null) {
- console.log("经纬度转换失败 error");
- return;
- }
- // console.log(evt[0].textContent);
- var point = evt[0].textContent;
- var jsonStr = '{"ExChangeRoot": {"Features": [' +
- ' { "type": "point", "featureName": "兴趣点", "Feature":[ { "Geometry": { "Points":[ { "Point": "' + point + '" } ]},' +
- '"Attribute": ' + myAttribute + ', "ToolTip": "' + myToolTip + '",' +
- '"ImgUrl":"' + myImgUrl + '" ,"ImgWidth":"' + myImgWidth + '","ImgHeight":"' + myImgHeight + '" } ] } ]}}';
- doGetGraphicByJson(jsonStr, true);
- // console.log(jsonStr);
- }
- function setPointBylonlatForGrid(x, y) {
- var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
- WsCommonClass("ConvertLonLatToXY", ["lon", "lat"], [x, y], getXYbylonlatforGrid, null, url);
- }
- function getXYbylonlatforGrid(evt) {
- if (evt[0] == null) {
- console.log("经纬度转换失败 error");
- return;
- }
- // console.log(evt[0].textContent);
- var point = evt[0].textContent;
- identifyTask(point, identifyTaskcallbackfun);
- }
- function identifyTaskcallbackfun(results) {
- window.parent.postMessage(
- {
- method: "identifyTaskcallbackfun",
- data: [results]
- },
- '*'
- );
- }
- function setPointBylonlatForAddress(x, y) {
- var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
- WsCommonClass("ConvertLonLatToXY", ["lon", "lat"], [x, y], getXYbylonlatforAddress, null, url);
- }
- function getXYbylonlatforAddress(evt) {
- if (evt[0] == null) {
- console.log("经纬度转换失败 error");
- return;
- }
- // console.log(evt[0].textContent);
- var point = evt[0].textContent;
- // var url = GetConfigDataByName("WebServiceExtraURL");
- // WsCommonClass("GetAddress",["x","y"],[point.split(',')[0],point.split(',')[1]],getAddressCallback,null,url);
- GetAddressByXY(point.split(',')[0], point.split(',')[1], 50);
- }
- function getAddressCallback(evt) {
- if (evt[0] == null) {
- console.log("经纬度转换失败 error");
- return;
- }
- var address = evt[0].textContent;
- window.parent.postMessage(
- {
- method: "addressdataCallback",
- data: [address]
- },
- '*'
- );
- }
- var m_radius;
- var m_layername;
- var m_showGraphic;
- function setPointBylonlatForGetBuffer(x, y, layername, radius, isshow, isGoTo) {
- m_radius = radius;
- m_layername = layername;
- m_showGraphic = isshow;
- var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
- WsCommonClass("ConvertLonLatToXY", ["lon", "lat"], [x - 0, y - 0], getXYbylonlatforBuffer, isGoTo, url);
- }
- function getXYbylonlatforBuffer(evt, isGoTo) {
- if (evt[0] == null) {
- console.log("经纬度转换失败 error");
- return;
- }
- var point = evt[0].textContent;
- // var buffer = getBufferByPoint(point.split(',')[0],point.split(',')[1],m_radius);
- getBufferByPoint(point.split(',')[0], point.split(',')[1], m_radius, m_layername, m_showGraphic, isGoTo);
- //m_layername;
- // queryByGeometryAndLayer(buffer,m_layername);
- }
- function getGridGeometry(grid, layername) {
- getGridGeometryByGridID(grid, layername);
- }
- function setPointBylonlatForSetCenter(x, y) {
- var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
- WsCommonClass("ConvertLonLatToXY", ["lon", "lat"], [x - 0, y - 0], getPointBylonlatForSetCenterr, null, url);
- }
- function getPointBylonlatForSetCenterr(evt) {
- if (evt[0] == null) {
- console.log("经纬度转换失败 error");
- return;
- }
- var point = evt[0].textContent;
- m_view.center.x = point.split(',')[0] - 0;
- m_view.center.y = point.split(',')[1] - 0;
- m_view.goTo({
- target: m_view.center
- });
- // m_view.center = [point.split(',')[0]-0,point.split(',')[1]-0];
- }
- var callMeasureLengthfun;
- function MeasureLengthByPoint(x, y, x1, y1, fun) {
- callMeasureLengthfun = fun;
- var url = GetConfigDataByName("WebServiceConvertCoordinateURL");
- var sql = "121,31;121,31.1";
- sql = x + "," + y + ";" + x1 + "," + y1;
- WsCommonClass("ConvertLonLatToXYMass", ["lonAndLatGroup"], [sql], getXYbylonlatMass, null, url);
- }
- function getXYbylonlatMass(evt) {
- console.log(evt[0].textContent);
- var points = evt[0].textContent.split(';');
- var x = points[0].split(',')[0];
- var y = points[0].split(',')[1];
- var x1 = points[1].split(',')[0];
- var y1 = points[1].split(',')[1];
- var len = measurePolylineByPoint(x, y, x1, y1);
- // parent.eval(callMeasureLengthfun+"("+ len+")");
- window.parent.postMessage(
- {
- method: callMeasureLengthfun,
- data: [len]
- },
- '*'
- );
- }
- function getXYbyAddress(str) {
- var url = GetConfigDataByName("WebServiceExtraURL");
- WsCommonClass("GetStreetInfo", ["address"], [str], getXYbyAddressCallback, null, url);
- }
- function getXYbyAddressCallback(evt) {
- if (evt[0] == null) {
- console.log("error");
- return;
- }
- // var jsonArray = $.xml2json(evt[0].textContent);
- var jsonArray = $.xml2json(evt[0].innerHTML);
- // var jsonArray = xmltojson(evt[0].textContent);
- //var jsonArray =JSON.parse(evt[0].textContent)[0].data;
- window.parent.postMessage(
- {
- method: "XYbyAddressCallback",
- data: [JSON.stringify(jsonArray).replace(/\"/g, '"')]
- },
- '*'
- );
- }
- function newOpenFeatureLayer(layername, type, name, isGoTo, isOpen) {
- newOpenLayer(layername, type, name, isGoTo, isOpen);
- }
- function popupClick(json) {
- postToParentPageMethed("popupClickReturn", [json]);
- }
- function sqlReturn(evt, keyValue) {
- require(["esri/geometry/Extent", "esri/Graphic"],
- function (Extent, Graphic) {
- var allCount;
- var pageIndex;
- var jsonArray;
- if (evt[0] != null) {
- allCount = JSON.parse(evt[0].textContent)[0].AllCount;
- pageIndex = JSON.parse(evt[0].textContent)[0].pageIndex;
- jsonArray = JSON.parse(evt[0].textContent)[0].data;
- } else {
- jsonArray = []
- }
- switch (keyValue) {
- case "queryResetNumByType":
- {
- var TestData1 = [];
- var TestData2 = [];
- for (var i = 0; i < jsonArray.length; i++) {
- TestData1.push([{
- name: jsonArray[i].water_source_name,
- xy: [jsonArray[i].x1, jsonArray[i].y1]
- },
- {name: jsonArray[i].water_work_name, xy: [jsonArray[i].x2, jsonArray[i].y2]}]);
- TestData2.push([{
- name: jsonArray[i].water_work_name,
- xy: [jsonArray[i].x2, jsonArray[i].y2]
- },
- {name: jsonArray[i].area_name, xy: [jsonArray[i].x3, jsonArray[i].y3]}]);
- }
- echartsWaterSourceToWorkRoute(TestData1, "#3581FF", "", 4);
- echartsWaterWorkToAreaRoute(TestData2, "#42ebff", "", 4);
- break;
- }
- }
- })
- }
- </script>
- </head>
- <body>
- <div id="mapDiv">
- <!--<div id="viewTest">-->
- <!--<button onclick="layerOnOff();">图层开关</button>-->
- <!--</div>-->
- </div>
- <div id="infoDialog" title="详细信息">
- <div id="divShowResult"></div>
- </div>
- </body>
- </html>
|