GSFunction.js 151 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741
  1. function toFullExtent() {
  2. goToZoom(0,0);
  3. m_view.zoom = 1
  4. }
  5. function btFullExtent_Click() {
  6. toFullExtent()
  7. }
  8. function ZoomIn(level) {
  9. if (level) {
  10. m_view.goTo({
  11. zoom: level
  12. });
  13. } else if (level == 0) {
  14. m_view.goTo({
  15. zoom: 0
  16. });
  17. } else {
  18. m_zoom.zoomIn();
  19. }
  20. }
  21. function btZoomIn_Click() {
  22. ZoomIn()
  23. }
  24. function btZoomOut_Click() {
  25. ZoomOut()
  26. }
  27. function ZoomOut(level) {
  28. if (level) {
  29. m_view.goTo({
  30. zoom: level
  31. });
  32. } else if (level == 0) {
  33. m_view.goTo({
  34. zoom: 0
  35. });
  36. } else {
  37. m_zoom.zoomOut();
  38. }
  39. }
  40. function btDrawPolygon_Click() {
  41. measureSquare()
  42. }
  43. function measureSquare() {
  44. measurePolygon(m_drawtool, m_view)
  45. }
  46. function measureLength() {
  47. if (currentMapMode == "2D") {
  48. measurePolyline(m_drawtool, m_view)
  49. } else {
  50. if (lengthMeasureWidget) {
  51. if (!lengthMeasureWidget.destroyed) {
  52. lengthMeasureWidget.destroy();
  53. return
  54. }
  55. }
  56. createLengthMeasureWidget()
  57. }
  58. }
  59. function goToCar(x,y) {
  60. require([
  61. "esri/geometry/Point"
  62. ], function ( Point ) {
  63. var point = new Point({
  64. x: x-0,
  65. y: y-0,
  66. spatialReference: m_view.spatialReference
  67. });
  68. m_view.goTo({
  69. target: point,
  70. zoom: 8
  71. })
  72. })
  73. }
  74. function btDrawPolyline_Click() {
  75. measureLength()
  76. }
  77. function createLengthMeasureWidget() {
  78. require(["esri/widgets/DirectLineMeasurement3D", "dojo/domReady!"],
  79. function (DirectLineMeasurement3D) {
  80. lengthMeasureWidget = new DirectLineMeasurement3D({
  81. view: m_view
  82. });
  83. m_view.ui.add(lengthMeasureWidget, "top-right");
  84. });
  85. }
  86. function measurePolylineByPoint(x, y, x1, y1) {
  87. var length;
  88. require(["esri/Map", "esri/views/MapView", "esri/layers/MapImageLayer", "esri/layers/TileLayer", "esri/geometry/Geometry", "esri/geometry/Extent", "esri/tasks/GeometryService", "esri/layers/GraphicsLayer", "esri/widgets/ScaleBar", "esri/WebMap", "esri/geometry/SpatialReference", "esri/Graphic", "esri/views/2d/draw/Draw", "esri/geometry/Polyline", "esri/geometry/geometryEngine"],
  89. function (Map, MapView, MapImageLayer, TileLayer, Geometry, Extent, GeometryService, GraphicsLayer, ScaleBar, WebMap, SpatialReference, Graphic, Draw, Polyline, geometryEngine) {
  90. var polyline = new Polyline({
  91. paths: [[x, y], [x1, y1]],
  92. spatialReference: 2379
  93. });
  94. length = geometryEngine.planarLength(polyline, "kilometers");
  95. });
  96. return length;
  97. }
  98. function measurePolyline(draw, view) {
  99. require(["esri/Map", "esri/views/MapView", "esri/layers/MapImageLayer", "esri/layers/TileLayer", "esri/geometry/Geometry", "esri/geometry/Extent", "esri/tasks/GeometryService", "esri/layers/GraphicsLayer", "esri/widgets/ScaleBar", "esri/WebMap", "esri/geometry/SpatialReference", "esri/Graphic", "esri/views/2d/draw/Draw", "esri/geometry/Polyline", "esri/geometry/geometryEngine"],
  100. function (Map, MapView, MapImageLayer, TileLayer, Geometry, Extent, GeometryService, GraphicsLayer, ScaleBar, WebMap, SpatialReference, Graphic, Draw, Polyline, geometryEngine) {
  101. var action = draw.create("polyline");
  102. view.focus();
  103. action.on("vertex-add", drawPolyline);
  104. action.on("cursor-update", drawPolyline);
  105. action.on("vertex-remove", drawPolyline);
  106. action.on("draw-complete", drawPolyline);
  107. function drawPolyline(evt) {
  108. var vertices = evt.vertices;
  109. btClear_Click();
  110. var polyline = createPolyline(vertices);
  111. var graphic = createGraphic(polyline);
  112. GraphicsLayer_DrawLayer.add(graphic);
  113. var length = geometryEngine.planarLength(polyline, "kilometers");
  114. if (length < 0) {
  115. var simplifiedPolyline = geometryEngine.simplify(polyline);
  116. if (simplifiedPolyline) {
  117. if (currentMapMode == "2D") {
  118. length = geometryEngine.planarLength(simplifiedPolyline, "kilometers")
  119. } else {
  120. length = geometryEngine.geodesicLength(simplifiedPolyline, "kilometers")
  121. }
  122. }
  123. }
  124. labelLength(polyline, length)
  125. }
  126. function createPolyline(vertices) {
  127. return new Polyline({
  128. paths: vertices,
  129. spatialReference: m_view.spatialReference
  130. })
  131. }
  132. function createGraphic(polyline) {
  133. graphic = new Graphic({
  134. geometry: polyline,
  135. symbol: {
  136. type: "simple-line",
  137. color: [178, 102, 234, .8],
  138. width: 2
  139. }
  140. });
  141. return graphic
  142. }
  143. function labelLength(geom, area) {
  144. var graphic = new Graphic({
  145. geometry: geom.extent.center,
  146. symbol: {
  147. type: "text",
  148. color: "black",
  149. haloColor: "black",
  150. haloSize: "1px",
  151. text: area.toFixed(2) + " km",
  152. xoffset: 3,
  153. yoffset: 3,
  154. font: {
  155. size: 14,
  156. family: "sans-serif"
  157. }
  158. }
  159. });
  160. GraphicsLayer_DrawLayer.add(graphic)
  161. }
  162. })
  163. }
  164. function measurePolygon(draw, view) {
  165. require(["esri/Map", "esri/views/MapView", "esri/layers/MapImageLayer", "esri/layers/TileLayer", "esri/geometry/Geometry", "esri/geometry/Extent", "esri/tasks/GeometryService", "esri/layers/GraphicsLayer", "esri/widgets/ScaleBar", "esri/WebMap", "esri/geometry/SpatialReference", "esri/Graphic", "esri/views/2d/draw/Draw", "esri/geometry/Polygon", "esri/geometry/geometryEngine"],
  166. function (Map, MapView, MapImageLayer, TileLayer, Geometry, Extent, GeometryService, GraphicsLayer, ScaleBar, WebMap, SpatialReference, Graphic, Draw, Polygon, geometryEngine) {
  167. var action = draw.create("polygon");
  168. view.focus();
  169. action.on("vertex-add", drawPolygon);
  170. action.on("cursor-update", drawPolygon);
  171. action.on("vertex-remove", drawPolygon);
  172. action.on("draw-complete", drawPolygon);
  173. function drawPolygon(evt) {
  174. var vertices = evt.vertices;
  175. btClear_Click();
  176. var polygon = createPolygon(vertices);
  177. var graphic = createGraphic(polygon);
  178. GraphicsLayer_DrawLayer.add(graphic);
  179. var area = geometryEngine.planarArea(polygon, "square-kilometers");
  180. if (area < 0) {
  181. var simplifiedPolygon = geometryEngine.simplify(polygon);
  182. if (simplifiedPolygon) {
  183. if (currentMapMode == "2D") {
  184. area = geometryEngine.planarArea(simplifiedPolygon, "square-kilometers")
  185. } else {
  186. area = geometryEngine.geodesicArea(simplifiedPolygon, "square-kilometers")
  187. }
  188. }
  189. }
  190. labelAreas(polygon, area)
  191. }
  192. function createPolygon(vertices) {
  193. return new Polygon({
  194. rings: vertices,
  195. spatialReference: m_view.spatialReference
  196. })
  197. }
  198. function createGraphic(polygon) {
  199. graphic = new Graphic({
  200. geometry: polygon,
  201. symbol: {
  202. type: "simple-fill",
  203. color: [178, 102, 234, .8],
  204. style: "solid",
  205. outline: {
  206. color: [255, 255, 255],
  207. width: 2
  208. }
  209. }
  210. });
  211. return graphic
  212. }
  213. function labelAreas(geom, area) {
  214. var graphic = new Graphic({
  215. geometry: geom.centroid,
  216. symbol: {
  217. type: "text",
  218. color: "black",
  219. haloColor: "black",
  220. haloSize: "1px",
  221. text: area.toFixed(2) + " 平方千米",
  222. xoffset: 3,
  223. yoffset: 3,
  224. font: {
  225. size: 14,
  226. family: "sans-serif"
  227. }
  228. }
  229. });
  230. GraphicsLayer_DrawLayer.add(graphic)
  231. }
  232. })
  233. }
  234. function btPrintPicture_Click() {
  235. downLoadPicture()
  236. }
  237. function downLoadPicture() {
  238. if (m_printTool) {
  239. if (!m_printTool.destroyed) {
  240. m_printTool.destroy();
  241. return
  242. }
  243. }
  244. require(["esri/widgets/Print"],
  245. function (Print) {
  246. m_printTool = new Print({
  247. view: m_view,
  248. printServiceUrl: GetConfigDataByName("PrintTaskURL")
  249. });
  250. m_view.ui.add(m_printTool, "top-right")
  251. })
  252. }
  253. function btPrintPicture_Click2() {
  254. require(["esri/tasks/PrintTask", "esri/tasks/support/PrintParameters", "esri/tasks/support/PrintTemplate"],
  255. function (PrintTask, PrintParameters, PrintTemplate) {
  256. var printTask = new PrintTask(GetConfigDataByName("PrintTaskURL"));
  257. var template = new PrintTemplate;
  258. template.exportOptions = {
  259. width: 1200,
  260. height: 700,
  261. dpi: 96
  262. };
  263. template.format = "JPG";
  264. template.layout = "MAP_ONLY";
  265. template.preserveScale = true;
  266. var params = new PrintParameters;
  267. params.view = m_view;
  268. params.template = template;
  269. printTask.execute(params).then(function (evt) {
  270. window.open(evt.url, "_blank")
  271. })
  272. })
  273. }
  274. function btGetGraphicByJson() {
  275. var jsonStr = '{"ExChangeRoot": {"Features": [' + ' { "type": "polygon", "featureName": "用地", "Feature":[ {"Geometry": { "Rings": [{ "Ring": "1000,-1000|0,-1500|-1000,-1000|-1000,1000|1000,1000|2000,0" } ]},"Attribute": { "ID": "1", "地块面积": "100", "建筑限高": "20" }, "ToolTip": "用地地块","Color": "yellow", "Style": "solid" } ] },' + '{ "type": "polyline", "featureName": "道路", "Feature": [{"ShowInfo":"yes", "Geometry": {"Paths": [{ "Path": "3778,-2008|2777,-2816|3777,-3021|3777,-3529|3772,-3928|3774,-4405|3777,-5206" }] }, "Attribute": {"ID": "2","道路名": "人民大道", "道路长度": "10000", "道路宽度": "25" }, "ToolTip": "人民大道", "Color": [225,0,0,0.5], "Size": "5" }] },' + '{ "type": "point", "featureName": "兴趣点", "Feature":[ { "Geometry": { "Points":[ { "Point": "2600,900" } ]},"Attribute": { "ID": "3","名称": "东方明珠" }, "ToolTip": "东方明珠","Color": "blue", "Size": "10", "Style": "square"}]}]}}';
  276. doGetGraphicByJson(jsonStr)
  277. }
  278. function jsontagUndefined(firstChild) {
  279. if (firstChild != undefined) {
  280. return firstChild
  281. }
  282. return null
  283. }
  284. function attributesToHTMLStr(att) {
  285. var str = "";
  286. for (var name in att) {
  287. str += name + ":" + att[name] + "<br>"
  288. }
  289. return str
  290. }
  291. function polygonxmlToArray(xmlStr) {
  292. var end = [];
  293. var strs = xmlStr.split("|");
  294. for (var i = 0; i < strs.length; i++) {
  295. var s = strs[i].split(",");
  296. if (currentMapMode == "2D") {
  297. var aa = [parseFloat(s[0]), parseFloat(s[1])];
  298. end.push(aa)
  299. } else {
  300. var aa = [parseFloat(s[0]), parseFloat(s[1]), parseFloat(s[2])];
  301. end.push(aa)
  302. }
  303. end.push(aa)
  304. }
  305. end.push([parseFloat(strs[0].split(",")[0]), parseFloat(strs[0].split(",")[1])]);
  306. return end
  307. }
  308. function polylinexmlToArray(xmlStr) {
  309. var end = [];
  310. var strs = xmlStr.split("|");
  311. for (var i = 0; i < strs.length; i++) {
  312. var s = strs[i].split(",");
  313. if (currentMapMode == "2D") {
  314. var aa = [parseFloat(s[0]), parseFloat(s[1])];
  315. end[i] = aa
  316. } else {
  317. var aa = [parseFloat(s[0]), parseFloat(s[1]), parseFloat(s[2])];
  318. end[i] = aa
  319. }
  320. }
  321. return end
  322. }
  323. var imgSizeList = [];
  324. function doGetGraphicByJson(jsons, isGoTo) {
  325. var jsonStr = eval("(" + jsons + ")");
  326. btClear_Click();
  327. var features = jsonStr.ExChangeRoot.Features;
  328. if (features.length < 1) {
  329. alert("无查询结果")
  330. }
  331. for (var k = 0; k < features.length; k++) {
  332. switch (features[k].type) {
  333. case "polygon":
  334. {
  335. var polygonFeature = features[k].Feature;
  336. for (var i = 0; i < polygonFeature.length; i++) {
  337. var rings = polygonFeature[i].Geometry.Rings;
  338. for (var j = 0; j < rings.length; j++) {
  339. var ring = rings[j].Ring;
  340. var polygonAttribute = polygonFeature[i].Attribute;
  341. var polygonToolTip = jsontagUndefined(polygonFeature[i].ToolTip);
  342. var polygonColor = jsontagUndefined(polygonFeature[i].Color);
  343. var polygonSize = jsontagUndefined(polygonFeature[i].Size);
  344. var polygonStyle = jsontagUndefined(polygonFeature[i].Style);
  345. xmlAddPolygon(ring, polygonToolTip, polygonColor, polygonSize, polygonStyle, polygonAttribute)
  346. }
  347. }
  348. break;
  349. }
  350. case "polyline":
  351. {
  352. var polylineFeature = features[k].Feature;
  353. for (var i = 0; i < polylineFeature.length; i++) {
  354. var paths = polylineFeature[i].Geometry.Paths;
  355. for (var j = 0; j < paths.length; j++) {
  356. var path = paths[j].Path;
  357. var polylineAttribute = polylineFeature[i].Attribute;
  358. var polylineToolTip = jsontagUndefined(polylineFeature[i].ToolTip);
  359. var polylineColor = jsontagUndefined(polylineFeature[i].Color);
  360. var polylineSize = jsontagUndefined(polylineFeature[i].Size);
  361. var polylineStyle = jsontagUndefined(polylineFeature[i].Style);
  362. xmlAddPolyline(path, polylineToolTip, polylineColor, polylineSize, polylineStyle, polylineAttribute)
  363. }
  364. }
  365. break;
  366. }
  367. case "point":
  368. {
  369. var pointFeature = features[k].Feature;
  370. for (var i = 0; i < pointFeature.length; i++) {
  371. var points = pointFeature[i].Geometry.Points;
  372. for (var j = 0; j < points.length; j++) {
  373. var point = points[j].Point;
  374. var pointAttribute = pointFeature[i].Attribute;
  375. var pointToolTip = jsontagUndefined(pointFeature[i].ToolTip);
  376. var imgUrl = jsontagUndefined(pointFeature[i].ImgUrl);
  377. var ImgWidth = jsontagUndefined(pointFeature[i].ImgWidth);
  378. var ImgHeight = jsontagUndefined(pointFeature[i].ImgHeight);
  379. var color = jsontagUndefined(pointFeature[i].Color);
  380. var size = jsontagUndefined(pointFeature[i].Size);
  381. var style = jsontagUndefined(pointFeature[i].Style);
  382. xmlAddPoint(point, pointToolTip, imgUrl, ImgWidth, ImgHeight, color, size, style, pointAttribute)
  383. }
  384. }
  385. break;
  386. }
  387. }
  388. }
  389. m_view.zoom=10;
  390. if (isGoTo == undefined || isGoTo == null)
  391. isGoTo = true;
  392. if (isGoTo) {
  393. m_view.goTo(xmlQueryExtend.expand(2))
  394. }
  395. }
  396. function doDeletePointById(id) {
  397. var list = GraphicsLayer_DrawLayer.graphics.items;
  398. for (var i = 0; i < list.length; i++) {
  399. if (list[i].attributes.id == id) {
  400. GraphicsLayer_DrawLayer.remove(list[i]);
  401. }
  402. }
  403. }
  404. function doShowAreaName(layerName, fieldName, bool, size, color) {
  405. if (!bool) {
  406. GraphicsLayer_areaNameLayer.removeAll();
  407. return;
  408. }
  409. if (!color) {
  410. color = "black";
  411. }
  412. if (!size) {
  413. size = 14;
  414. }
  415. var layerId = GetFeatureLayerIdbyName(layerName);
  416. var where = "1=1";
  417. if (layerId == -1)
  418. return;
  419. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom", "esri/Graphic",
  420. "esri/geometry/Point"],
  421. function (QueryTask, Query, FeatureLayer, arrayUtils, dom, Graphic, Point) {
  422. var pointGraphicArray = [];
  423. var urlI = dyLayer.url + "/" + layerId;
  424. var qTask = new QueryTask({
  425. url: urlI
  426. });
  427. var params = new Query({
  428. returnGeometry: true,
  429. outFields: ["*"]
  430. });
  431. params.where = where;
  432. qTask.execute(params).then(getResults).catch(promiseRejected);
  433. function getResults(response) {
  434. $.each(response.features, function (index, feature) {
  435. var geometry = feature.geometry;
  436. var text = feature.attributes[fieldName];
  437. var point = {
  438. type: "point",
  439. x: geometry.extent.center.x,
  440. y: geometry.extent.center.y,
  441. spatialReference: m_view.spatialReference
  442. };
  443. var textSymbol = {
  444. type: "text", // autocasts as new TextSymbol()
  445. color: color,
  446. text: text,
  447. font: { // autocasts as new Font()
  448. size: size,
  449. weight: "bold"
  450. }
  451. };
  452. var pointGraphic = new Graphic({
  453. geometry: point,
  454. symbol: textSymbol
  455. });
  456. pointGraphicArray.push(pointGraphic);
  457. });
  458. GraphicsLayer_areaNameLayer.addMany(pointGraphicArray);
  459. }
  460. function promiseRejected(err) {
  461. console.error("错误信息: ", err.message);
  462. }
  463. });
  464. }
  465. function xmlAddPolygon(ring, polygonToolTip, polygonColor, polygonSize, polygonStyle, polygonAttribute) {
  466. require(["esri/Graphic", "esri/geometry/SpatialReference"],
  467. function (Graphic, SpatialReference) {
  468. if (!polygonColor) {
  469. polygonColor = [227, 139, 79, .8]
  470. }
  471. if (!polygonSize) {
  472. polygonSize = 2
  473. }
  474. switch (polygonStyle) {
  475. case "backwarddiagonal":
  476. polygonStyle = "backward-diagonal";
  477. break;
  478. case "cross":
  479. polygonStyle = "cross";
  480. break;
  481. case "diagonalcross":
  482. polygonStyle = "diagonal-cross";
  483. break;
  484. case "forwarddiagonal":
  485. polygonStyle = "forward-diagonal";
  486. break;
  487. case "horizontal":
  488. polygonStyle = "horizontal";
  489. break;
  490. case "vertical":
  491. polygonStyle = "vertical";
  492. break;
  493. case "solid":
  494. polygonStyle = "solid";
  495. break;
  496. default:
  497. polygonStyle = "none";
  498. break
  499. }
  500. var ringsarray = polygonxmlToArray(ring);
  501. var polygon = {
  502. type: "polygon",
  503. rings: ringsarray,
  504. spatialReference: m_view.spatialReference
  505. };
  506. var fillSymbol = {
  507. type: "simple-fill",
  508. color: polygonColor,
  509. style: polygonStyle,
  510. outline: {
  511. color: [255, 255, 255],
  512. width: polygonSize
  513. }
  514. };
  515. var polygonGraphic = new Graphic({
  516. geometry: polygon,
  517. symbol: fillSymbol,
  518. attributes: polygonAttribute
  519. });
  520. GraphicsLayer_DrawLayer.add(polygonGraphic);
  521. var popupTemplate = {
  522. title: polygonToolTip,
  523. content: attributesToHTMLStr(polygonAttribute)
  524. };
  525. // polygonGraphic.popupTemplate = popupTemplate;
  526. var extent = polygonGraphic.geometry.extent;
  527. extent.spatialReference = m_view.spatialReference;
  528. if (xmlQueryExtend) {
  529. xmlQueryExtend = xmlQueryExtend.union(extent)
  530. } else {
  531. xmlQueryExtend = extent
  532. }
  533. })
  534. }
  535. function xmlAddPolyline(path, polylineToolTip, polylineColor, polylineSize, polylineStyle, polylineAttribute) {
  536. require(["esri/Graphic"],
  537. function (Graphic) {
  538. if (polylineSize == null) {
  539. polylineSize = 1
  540. }
  541. if (polylineColor == null) {
  542. polylineColor = [226, 119, 40]
  543. }
  544. switch (polylineStyle) {
  545. case "dash":
  546. polylineStyle = "dash";
  547. break;
  548. case "dashdot":
  549. polylineStyle = "dash-dot";
  550. break;
  551. case "none":
  552. polylineStyle = "none";
  553. break;
  554. case "dot":
  555. polylineStyle = "dot";
  556. break;
  557. default:
  558. polylineStyle = "solid"
  559. }
  560. var polyline = {
  561. type: "polyline",
  562. paths: polylinexmlToArray(path),
  563. spatialReference: m_view.spatialReference
  564. };
  565. var lineSymbol = {
  566. type: "simple-line",
  567. color: polylineColor,
  568. style: polylineStyle,
  569. width: polylineSize
  570. };
  571. var polylineGraphic = new Graphic({
  572. geometry: polyline,
  573. symbol: lineSymbol,
  574. attributes: polylineAttribute
  575. });
  576. GraphicsLayer_DrawLayer.add(polylineGraphic);
  577. var popupTemplate = {
  578. title: polylineToolTip,
  579. content: attributesToHTMLStr(polylineAttribute)
  580. };
  581. // polylineGraphic.popupTemplate = popupTemplate;
  582. var extent = polylineGraphic.geometry.extent;
  583. extent.spatialReference = m_view.spatialReference;
  584. if (xmlQueryExtend) {
  585. xmlQueryExtend = xmlQueryExtend.union(extent)
  586. } else {
  587. xmlQueryExtend = extent
  588. }
  589. })
  590. }
  591. function xmlAddPoint(points, pointToolTip, imgUrl, imgWidth, imgHeight, color, size, style, pointAttribute) {
  592. require(["esri/geometry/Extent", "esri/Graphic"],
  593. function (Extent, Graphic) {
  594. var xy = points.split(",");
  595. var point;
  596. if (currentMapMode == "2D") {
  597. point = {
  598. type: "point",
  599. x: xy[0],
  600. y: xy[1],
  601. spatialReference: m_view.spatialReference
  602. }
  603. } else {
  604. var z=0;
  605. if(xy.length==3){
  606. z=xy[2];
  607. }else{
  608. z=10;
  609. }
  610. point = {
  611. type: "point",
  612. x: xy[0],
  613. y: xy[1],
  614. z: z,
  615. spatialReference: m_view.spatialReference
  616. }
  617. }
  618. var markerSymbol;
  619. if (imgUrl != null) {
  620. imgSizeList = [imgWidth.split("px")[0], imgHeight.split("px")[0]];
  621. pointAttribute.newImgWidth=imgSizeList[0];
  622. pointAttribute.newImgHeight=imgSizeList[1];
  623. var newImgWidth = imgSizeList[0] - (imgSizeList[0] * (14 - m_view.zoom) * 0.05);//zoom每级差5%
  624. var newImgHeight = imgSizeList[1] - (imgSizeList[1] * (14 - m_view.zoom) * 0.05)
  625. markerSymbol =
  626. {
  627. type: "point-3d", // autocasts as new PointSymbol3D()
  628. symbolLayers: [
  629. {
  630. type: "icon", // autocasts as new IconSymbol3DLayer()
  631. resource: {
  632. href: imgUrl
  633. },
  634. size: newImgWidth,
  635. outline: {
  636. color: "white",
  637. size: 2
  638. }
  639. }
  640. ],
  641. verticalOffset:{
  642. screenLength: 20,
  643. maxWorldLength: 200,
  644. minWorldLength: 10
  645. },
  646. callout: {
  647. type: "line", // autocasts as new LineCallout3D()
  648. color: "#36B1E8",
  649. size: 0,
  650. border: {
  651. color: "#36B1E8"
  652. }
  653. }
  654. }
  655. } else {
  656. if (color == null) {
  657. color = [226, 119, 40]
  658. }
  659. if (size == null) {
  660. size = 2
  661. }
  662. switch (style) {
  663. case "x":
  664. style = "x";
  665. break;
  666. case "diamond":
  667. style = "diamond";
  668. break;
  669. case "cross":
  670. style = "cross";
  671. break;
  672. case "square":
  673. style = "square";
  674. break;
  675. default:
  676. style = "circle"
  677. }
  678. markerSymbol = {
  679. type: "simple-marker",
  680. color: color,
  681. style: style,
  682. size: size
  683. }
  684. }
  685. // debugger;
  686. var pointGraphic = new Graphic({
  687. geometry: point,
  688. symbol: markerSymbol,
  689. attributes: pointAttribute
  690. });
  691. var textSymbol = {
  692. type: "text", // autocasts as new TextSymbol()
  693. color: [254, 238, 175],
  694. text: pointAttribute.名称,
  695. yoffset: "35px",
  696. font: { // autocasts as new Font()
  697. size: 14
  698. }
  699. };
  700. var textGraphic = new Graphic({
  701. geometry: point,
  702. symbol: textSymbol
  703. });
  704. GraphicsLayer_DrawLayer.add(textGraphic);
  705. GraphicsLayer_DrawLayer.add(pointGraphic);
  706. var popupTemplate = {
  707. title: pointToolTip,
  708. content: attributesToHTMLStr(pointAttribute)
  709. };
  710. // pointGraphic.popupTemplate = popupTemplate;
  711. var extent = new Extent({
  712. xmax: pointGraphic.geometry.x - 0 + 250,
  713. ymax: pointGraphic.geometry.y - 0 + 250,
  714. xmin: pointGraphic.geometry.x - 250,
  715. ymin: pointGraphic.geometry.y - 250,
  716. spatialReference: m_view.spatialReference
  717. });
  718. if (xmlQueryExtend) {
  719. xmlQueryExtend = xmlQueryExtend.union(extent)
  720. } else {
  721. xmlQueryExtend = extent
  722. }
  723. })
  724. }
  725. function xmlAddPointJCZ(x,y, pointToolTip, imgUrl, imgWidth, imgHeight, color, size, style, pointAttribute,radius) {
  726. require(["esri/geometry/Extent", "esri/Graphic","esri/geometry/Circle"],
  727. function (Extent, Graphic,Circle) {
  728. var point;
  729. point = {
  730. type: "point",
  731. x: x,
  732. y: y,
  733. spatialReference: m_view.spatialReference
  734. }
  735. var markerSymbol;
  736. if (color == null) {
  737. color = [0, 0, 0]
  738. }
  739. if (size == null) {
  740. size = 10
  741. }
  742. /*switch (style) {
  743. case "x":
  744. style = "x";
  745. break;
  746. case "diamond":
  747. style = "diamond";
  748. break;
  749. case "cross":
  750. style = "cross";
  751. break;
  752. case "square":
  753. style = "square";
  754. break;
  755. default:
  756. style = "circle"
  757. }*/
  758. markerSymbol = {
  759. type: "simple-marker",
  760. color: color,
  761. style: "circle",
  762. size: size
  763. };
  764. // debugger;
  765. var pointGraphic = new Graphic({
  766. geometry: point,
  767. symbol: markerSymbol,
  768. attributes: pointAttribute
  769. });
  770. var polygon =new Circle( {
  771. type: "circle",
  772. center:point,
  773. radius: radius,
  774. spatialReference: m_view.spatialReference
  775. });
  776. var fillSymbol = {
  777. type: "simple-fill",
  778. color:[255, 0, 0,0.3],
  779. style: "solid",
  780. outline: {
  781. color: [255, 255, 255,0.3],
  782. width: 1
  783. }
  784. };
  785. var circle = new Graphic({
  786. geometry: polygon,
  787. symbol: fillSymbol
  788. });
  789. //蓝[0,0,255] 绿[0,255,0] 黄[255,255,0]
  790. GraphicsLayer_DrawLayer.add(pointGraphic);
  791. GraphicsLayer_DrawLayer.add(circle);
  792. })
  793. }
  794. function btnCircle_Click() {
  795. drawSquare()
  796. }
  797. function drawSquare() {
  798. require(["esri/Map", "esri/views/MapView", "esri/layers/MapImageLayer", "esri/layers/TileLayer", "esri/geometry/Geometry", "esri/geometry/Extent", "esri/tasks/GeometryService", "esri/layers/GraphicsLayer", "esri/widgets/ScaleBar", "esri/WebMap", "esri/geometry/SpatialReference", "esri/Graphic", "esri/views/2d/draw/Draw", "esri/geometry/Polygon", "esri/geometry/geometryEngine"],
  799. function (Map, MapView, MapImageLayer, TileLayer, Geometry, Extent, GeometryService, GraphicsLayer, ScaleBar, WebMap, SpatialReference, Graphic, Draw, Polygon, geometryEngine) {
  800. var action = m_drawtool.create("polygon");
  801. m_view.focus();
  802. action.on("vertex-add", drawPolygon);
  803. action.on("cursor-update", drawPolygon);
  804. action.on("vertex-remove", drawPolygon);
  805. action.on("draw-complete", drawPolygon);
  806. function drawPolygon(evt) {
  807. var vertices = evt.vertices;
  808. btClear_Click();
  809. var polygon = createPolygon(vertices);
  810. var graphic = createGraphic(polygon);
  811. GraphicsLayer_DrawLayer.add(graphic);
  812. queryExtent = polygon
  813. }
  814. function createPolygon(vertices) {
  815. return new Polygon({
  816. rings: vertices,
  817. spatialReference: m_view.spatialReference
  818. })
  819. }
  820. function createGraphic(polygon) {
  821. graphic = new Graphic({
  822. geometry: polygon,
  823. symbol: {
  824. type: "simple-fill",
  825. color: [178, 102, 234, .8],
  826. style: "solid",
  827. outline: {
  828. color: [255, 255, 255],
  829. width: 2
  830. }
  831. }
  832. });
  833. return graphic
  834. }
  835. })
  836. }
  837. function btQuery_Click() {
  838. var Str = document.getElementById("txtQueryStr").value;
  839. var layerName = document.getElementById("txtQueryLayerName").value;
  840. query(Str, layerName)
  841. }
  842. function query(Str, layerName) {
  843. queryGraphicByDylayer();
  844. var whereStr = "";
  845. if (Str == "") {
  846. whereStr = " 1=1 "
  847. } else {
  848. whereStr = " 1=2 ";
  849. var xmlDoc1 = xmlUtil.loadXmlFromFile("config/layerQueryName.xml");
  850. var layerXml = xmlDoc1.getElementsByTagName(layerName);
  851. var mapNodes = layerXml[0].childNodes;
  852. for (var i = 0; i < mapNodes.length; i++) {
  853. if (xmlUtil.getNodeTagName(mapNodes[i]) == "name") {
  854. whereStr += " or " + xmlUtil.getNodeValue(mapNodes[i]) + " like '%" + Str + "%' "
  855. }
  856. }
  857. }
  858. var layerId = GetLayerIdbyName(layerName);
  859. if (layerId == -1) {
  860. alert("没有此图层")
  861. } else {
  862. queryGraphicByDylayer(layerId, whereStr)
  863. }
  864. }
  865. function queryGraphicByDylayer(layerId, whereStr, geo) {
  866. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom"],
  867. function (QueryTask, Query, FeatureLayer, arrayUtils, dom) {
  868. btClear_Click();
  869. var urlI = dyLayer.url + "/" + layerId;
  870. var qTask = new QueryTask({
  871. url: urlI
  872. });
  873. var params = new Query({
  874. geometry: queryExtent,
  875. returnGeometry: true,
  876. outFields: ["*"]
  877. });
  878. params.geometry = geo || null;
  879. params.where = whereStr;
  880. qTask.execute(params).then(getResults).otherwise(promiseRejected);
  881. function getResults(response) {
  882. var peakResults = arrayUtils.map(response.features,
  883. function (feature) {
  884. var obj = eval("(" + symble[layerId] + ")");
  885. var symbolJson = obj.drawingInfo.renderer.symbol;
  886. if (currentMapMode == "2D") {
  887. if (symbolJson) {
  888. if (symbolJson.type == "esriSFS") {
  889. feature.symbol = {
  890. type: "simple-fill",
  891. style: changeStyle(symbolJson.style),
  892. color: symbolJson.color,
  893. outline: {
  894. style: changeStyle(symbolJson.outline.style),
  895. color: symbolJson.outline.color,
  896. width: symbolJson.outline.width
  897. }
  898. }
  899. } else if (symbolJson.type == "esriPMS") {
  900. feature.symbol = {
  901. type: "picture-marker",
  902. url: "data:image/png;base64," + symbolJson.imageData,
  903. width: symbolJson.width,
  904. height: symbolJson.height
  905. }
  906. } else if (symbolJson.type == "esriSMS") {
  907. feature.symbol = {
  908. type: "simple-marker",
  909. size: symbolJson.size,
  910. color: symbolJson.color,
  911. outline: symbolJson.outline
  912. }
  913. }
  914. } else {
  915. feature.symbol = {
  916. type: "simple-marker",
  917. color: rgba(255, 0, 0, 1),
  918. outline: {
  919. color: [0, 0, 0, 1],
  920. width: 1
  921. }
  922. }
  923. }
  924. } else {
  925. var verticalOffset = {
  926. screenLength: 40,
  927. maxWorldLength: 200,
  928. minWorldLength: 35
  929. };
  930. if (symbolJson.type == "esriSFS") {
  931. feature.symbol = {
  932. type: "polygon-3d",
  933. symbolLayers: [{
  934. type: "fill",
  935. material: {
  936. color: symbolJson.color
  937. }
  938. }],
  939. outline: {
  940. color: symbolJson.outline.color,
  941. size: symbolJson.outline.size
  942. }
  943. }
  944. } else if (symbolJson.type == "esriPMS") {
  945. feature.symbol = {
  946. type: "point-3d",
  947. symbolLayers: [{
  948. type: "icon",
  949. resource: {
  950. href: "data:image/png;base64," + symbolJson.imageData
  951. },
  952. size: 20,
  953. outline: {
  954. color: "white",
  955. size: 2
  956. }
  957. }],
  958. verticalOffset: verticalOffset,
  959. callout: {
  960. type: "line",
  961. color: "white",
  962. size: 2,
  963. border: {
  964. color: "#40C2B4"
  965. }
  966. }
  967. }
  968. } else if (symbolJson.style == "esriSMSCircle") {
  969. feature.symbol = {
  970. type: "point-3d",
  971. symbolLayers: [{
  972. type: "icon",
  973. resource: {
  974. primitive: "circle"
  975. },
  976. size: symbolJson.size * 2,
  977. material: {
  978. color: symbolJson.color
  979. },
  980. outline: {
  981. color: symbolJson.outline.color,
  982. size: symbolJson.outline.size
  983. }
  984. }],
  985. verticalOffset: verticalOffset,
  986. callout: {
  987. type: "line",
  988. color: "white",
  989. size: 2,
  990. border: {
  991. color: "#40C2B4"
  992. }
  993. }
  994. }
  995. }
  996. }
  997. feature.geometry.spatialReference = m_view.spatialReference;
  998. var popupTemplate = {
  999. title: "详细信息",
  1000. content: attributesToHTMLStr(feature.attributes)
  1001. };
  1002. feature.popupTemplate = popupTemplate;
  1003. return feature
  1004. });
  1005. GraphicsLayer_myLayer.addMany(peakResults);
  1006. m_view.goTo(peakResults)
  1007. }
  1008. function promiseRejected(err) {
  1009. console.error("错误信息: ", err.message)
  1010. }
  1011. })
  1012. }
  1013. function changeStyle(oldStyle) {
  1014. switch (oldStyle) {
  1015. case "esriSFSBackwardDiagonal":
  1016. oldStyle = "backward-diagonal";
  1017. break;
  1018. case "esriSFSCross":
  1019. oldStyle = "cross";
  1020. break;
  1021. case "esriSFSDiagonalCross":
  1022. oldStyle = "diagonal-cross";
  1023. break;
  1024. case "esriSFSForwardDiagonal":
  1025. oldStyle = "forward-diagonal";
  1026. break;
  1027. case "esriSFSHorizontal":
  1028. oldStyle = "horizontal";
  1029. break;
  1030. case "esriSFSNull":
  1031. oldStyle = "none";
  1032. break;
  1033. case "esriSFSSolid":
  1034. oldStyle = "solid";
  1035. break;
  1036. case "esriSFSVertical":
  1037. oldStyle = "vertical";
  1038. break;
  1039. case "esriSLSDash":
  1040. oldStyle = "dash";
  1041. break;
  1042. case "esriSLSDashDotDot":
  1043. oldStyle = "short-dash-dot-dot";
  1044. break;
  1045. case "esriSLSDot":
  1046. oldStyle = "dot";
  1047. break;
  1048. case "esriSLSNull":
  1049. oldStyle = "none";
  1050. break;
  1051. case "esriSLSDashDot":
  1052. oldStyle = "dash-dot";
  1053. break;
  1054. case "esriSLSSolid":
  1055. oldStyle = "solid";
  1056. break
  1057. }
  1058. return oldStyle
  1059. }
  1060. function openQuickQueryClick() {
  1061. document.getElementById("openQuickQuery").style.display = "none";
  1062. document.getElementById("quickQuery").style.display = "";
  1063. createSelect()
  1064. }
  1065. function closeQuickQueryClick() {
  1066. document.getElementById("openQuickQuery").style.display = "";
  1067. document.getElementById("quickQuery").style.display = "none"
  1068. }
  1069. function createSelect() {
  1070. var areaId = GetLayerIdbyName("特色街区");
  1071. var streetId = GetLayerIdbyName("街道乡镇");
  1072. queryOption(areaId, "areaName");
  1073. queryOption(streetId, "streetName")
  1074. }
  1075. function queryOption(layerId, selectId) {
  1076. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom"],
  1077. function (QueryTask, Query, FeatureLayer, arrayUtils, dom) {
  1078. var urlI = dyLayer.url + "/" + layerId;
  1079. var qTask = new QueryTask({
  1080. url: urlI
  1081. });
  1082. var params = new Query({
  1083. geometry: queryExtent,
  1084. returnGeometry: true,
  1085. outFields: ["*"]
  1086. });
  1087. params.where = "1=1";
  1088. qTask.execute(params).then(getResults).otherwise(promiseRejected);
  1089. function getResults(response) {
  1090. var peakResults = arrayUtils.map(response.features,
  1091. function (feature) {
  1092. return feature.attributes["名称"]
  1093. });
  1094. var option = "<option value='-1'>全部</option>";
  1095. for (var i = 0; i < peakResults.length; i++) {
  1096. option += "<option value='" + peakResults[i] + "'>" + peakResults[i] + "</option>"
  1097. }
  1098. document.getElementById(selectId).innerHTML = option
  1099. }
  1100. function promiseRejected(err) {
  1101. console.error("错误信息: ", err.message)
  1102. }
  1103. })
  1104. }
  1105. function changeAreaNameSelect() {
  1106. var optionValue = areaName.value;
  1107. if (optionValue == -1) {
  1108. GraphicsLayer_DrawLayer.removeAll();
  1109. queryExtent = null
  1110. } else {
  1111. var areaId = GetLayerIdbyName("特色街区");
  1112. queryGraphicBySelect(areaId, optionValue)
  1113. }
  1114. }
  1115. function changeStreetNameSelect() {
  1116. var optionValue = streetName.value;
  1117. if (optionValue == -1) {
  1118. GraphicsLayer_DrawLayer.removeAll();
  1119. queryExtent = null
  1120. } else {
  1121. var streetId = GetLayerIdbyName("街道乡镇");
  1122. queryGraphicBySelect(streetId, optionValue)
  1123. }
  1124. }
  1125. function queryGraphicBySelect(layerId, name) {
  1126. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "esri/Graphic", "dojo/dom"],
  1127. function (QueryTask, Query, FeatureLayer, arrayUtils, Graphic, dom) {
  1128. GraphicsLayer_DrawLayer.removeAll();
  1129. queryExtent = null;
  1130. var urlI = dyLayer.url + "/" + layerId;
  1131. var qTask = new QueryTask({
  1132. url: urlI
  1133. });
  1134. var params = new Query({
  1135. geometry: queryExtent,
  1136. returnGeometry: true,
  1137. outFields: ["*"]
  1138. });
  1139. params.where = "名称 = '" + name + "'";
  1140. qTask.execute(params).then(getResults).otherwise(promiseRejected);
  1141. function getResults(response) {
  1142. var peakResults = arrayUtils.map(response.features,
  1143. function (feature) {
  1144. if (currentMapMode == "2D") {
  1145. feature.symbol = {
  1146. type: "simple-fill",
  1147. style: "none",
  1148. color: null,
  1149. outline: {
  1150. style: "solid",
  1151. color: "red",
  1152. width: 2
  1153. }
  1154. };
  1155. feature.geometry.spatialReference = m_view.spatialReference;
  1156. queryExtent = feature.geometry;
  1157. feature.geometry.spatialReference = m_view.spatialReference;
  1158. return feature
  1159. } else {
  1160. for (var i = 0; i < feature.geometry.rings[0].length; i++) {
  1161. feature.geometry.rings[0][i].push(1)
  1162. }
  1163. var polygon = {
  1164. type: "polygon",
  1165. rings: feature.geometry.rings
  1166. };
  1167. var polygonGraphic = new Graphic({
  1168. geometry: polygon
  1169. });
  1170. polygonGraphic.symbol = {
  1171. type: "polygon-3d",
  1172. symbolLayers: [{
  1173. type: "fill",
  1174. material: {
  1175. color: [0, 0, 0, 0]
  1176. },
  1177. outline: {
  1178. color: "red",
  1179. size: "4px"
  1180. }
  1181. }]
  1182. }
  1183. }
  1184. queryExtent = feature.geometry;
  1185. polygonGraphic.geometry.spatialReference = m_view.spatialReference;
  1186. return polygonGraphic
  1187. });
  1188. GraphicsLayer_DrawLayer.addMany(peakResults);
  1189. m_view.goTo(peakResults[0].geometry.extent.expand(2))
  1190. }
  1191. function promiseRejected(err) {
  1192. console.error("错误信息: ", err.message)
  1193. }
  1194. })
  1195. }
  1196. function Polygon_Click() {
  1197. queryExtent = null;
  1198. require(["esri/Map", "esri/views/MapView", "esri/layers/MapImageLayer", "esri/layers/TileLayer", "esri/geometry/Geometry", "esri/geometry/Extent", "esri/tasks/GeometryService", "esri/layers/GraphicsLayer", "esri/widgets/ScaleBar", "esri/WebMap", "esri/geometry/SpatialReference", "esri/Graphic", "esri/views/2d/draw/Draw", "esri/geometry/Polygon", "esri/geometry/geometryEngine"],
  1199. function (Map, MapView, MapImageLayer, TileLayer, Geometry, Extent, GeometryService, GraphicsLayer, ScaleBar, WebMap, SpatialReference, Graphic, Draw, Polygon, geometryEngine) {
  1200. var action = m_drawtool.create("polygon");
  1201. m_view.focus();
  1202. action.on("vertex-add", drawPolygon);
  1203. action.on("cursor-update", drawPolygon);
  1204. action.on("vertex-remove", drawPolygon);
  1205. action.on("draw-complete", drawPolygon);
  1206. function drawPolygon(evt) {
  1207. var vertices = evt.vertices;
  1208. GraphicsLayer_DrawLayer.removeAll();
  1209. var polygon = createPolygon(vertices);
  1210. var graphic = createGraphic(polygon);
  1211. GraphicsLayer_DrawLayer.add(graphic);
  1212. queryExtent = polygon
  1213. }
  1214. function createPolygon(vertices) {
  1215. return new Polygon({
  1216. rings: vertices,
  1217. spatialReference: m_view.spatialReference
  1218. })
  1219. }
  1220. function createGraphic(polygon) {
  1221. graphic = new Graphic({
  1222. geometry: polygon,
  1223. symbol: {
  1224. type: "simple-fill",
  1225. style: "none",
  1226. color: null,
  1227. outline: {
  1228. style: "solid",
  1229. color: "red",
  1230. width: 2
  1231. }
  1232. }
  1233. });
  1234. return graphic
  1235. }
  1236. })
  1237. }
  1238. function btnQuickQuery() {
  1239. queryList.splice(0, queryList.length);
  1240. var layerName = select_zylx.value;
  1241. var zymc = txt_zymc.value;
  1242. var keyStr = txt_keyStr.value;
  1243. dynamicLayerURL = GetConfigDataByName("QueryLayer");
  1244. var layerId = GetLayerIdbyName(layerName);
  1245. var whereStr = " 1=1 ";
  1246. var optgroup = select_zylx.options[select_zylx.selectedIndex].parentNode.attributes;
  1247. if (optgroup["label"]) {
  1248. if (zymc) {
  1249. switch (layerName) {
  1250. case "ETPS":
  1251. whereStr += " and ETPS_NAME like '%" + zymc + "%' ";
  1252. break;
  1253. case "PE":
  1254. whereStr += " and NAME like '%" + zymc + "%' ";
  1255. break;
  1256. case "CORP":
  1257. whereStr += " and CORP_NAME like '%" + zymc + "%' ";
  1258. break
  1259. }
  1260. }
  1261. if (keyStr) {
  1262. whereStr += "and ADDRESS like '%" + keyStr + "%'"
  1263. }
  1264. } else {
  1265. if (layerName == "YDYZ") {
  1266. if (zymc) {
  1267. whereStr += "and MDNAME like '%" + zymc + "%'"
  1268. }
  1269. if (keyStr) {
  1270. whereStr += "and ADDRESS like '%" + keyStr + "%'"
  1271. }
  1272. } else {
  1273. if (zymc) {
  1274. whereStr += "and 载体名称 like '%" + zymc + "%'"
  1275. }
  1276. if (keyStr) {
  1277. whereStr += "and 载体地址 like '%" + keyStr + "%'"
  1278. }
  1279. }
  1280. }
  1281. doQuickQuery(layerId, whereStr)
  1282. }
  1283. function doQuickQuery(layerId, whereStr) {
  1284. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom"],
  1285. function (QueryTask, Query, FeatureLayer, arrayUtils, dom) {
  1286. var layerStr = "";
  1287. var layerName = select_zylx.value;
  1288. var optgroup = select_zylx.options[select_zylx.selectedIndex].parentNode.attributes;
  1289. if (optgroup["label"]) {
  1290. switch (layerName) {
  1291. case "ETPS":
  1292. layerStr = "ETPS_NAME";
  1293. break;
  1294. case "PE":
  1295. layerStr = "NAME";
  1296. break;
  1297. case "CORP":
  1298. layerStr = "CORP_NAME";
  1299. break
  1300. }
  1301. } else {
  1302. if (layerName == "YDYZ") {
  1303. layerStr = "MDNAME"
  1304. } else {
  1305. layerStr = "载体名称"
  1306. }
  1307. }
  1308. GraphicsLayer_fickerLayer.removeAll();
  1309. GraphicsLayer_myLayer.removeAll();
  1310. if (!dynamicLayerURL) {
  1311. dynamicLayerURL = GetConfigDataByName("QueryLayer")
  1312. }
  1313. var urlI = dynamicLayerURL + "/" + layerId;
  1314. var qTask = new QueryTask({
  1315. url: urlI
  1316. });
  1317. var params = new Query({
  1318. geometry: queryExtent,
  1319. returnGeometry: true,
  1320. outFields: ["*"]
  1321. });
  1322. params.where = whereStr;
  1323. qTask.execute(params).then(getResults).otherwise(promiseRejected);
  1324. function getResults(response) {
  1325. var peakResults = arrayUtils.map(response.features,
  1326. function (feature) {
  1327. if (currentMapMode == "2D") {
  1328. var obj = eval("(" + symble[layerId] + ")");
  1329. var symbolJson = obj.drawingInfo.renderer.symbol;
  1330. if (symbolJson.type == "esriSFS") {
  1331. feature.symbol = {
  1332. type: "simple-fill",
  1333. style: changeStyle(symbolJson.style),
  1334. color: symbolJson.color,
  1335. outline: {
  1336. style: changeStyle(symbolJson.outline.style),
  1337. color: symbolJson.outline.color,
  1338. width: symbolJson.outline.width
  1339. }
  1340. }
  1341. } else if (symbolJson.type == "esriPMS") {
  1342. feature.symbol = {
  1343. type: "picture-marker",
  1344. url: "data:image/png;base64," + symbolJson.imageData,
  1345. width: symbolJson.width,
  1346. height: symbolJson.height
  1347. }
  1348. } else if (symbolJson.style == "esriSMSCircle") {
  1349. feature.symbol = {
  1350. type: "simple-marker",
  1351. style: "circle",
  1352. color: symbolJson.color,
  1353. size: symbolJson.size,
  1354. outline: {
  1355. color: symbolJson.outline.color,
  1356. width: symbolJson.outline.width
  1357. }
  1358. }
  1359. }
  1360. } else {
  1361. var verticalOffset = {
  1362. screenLength: 40,
  1363. maxWorldLength: 200,
  1364. minWorldLength: 35
  1365. };
  1366. var obj = eval("(" + symble[layerId] + ")");
  1367. var symbolJson = obj.drawingInfo.renderer.symbol;
  1368. if (symbolJson.type == "esriSFS") {
  1369. } else if (symbolJson.type == "esriPMS") {
  1370. feature.symbol = {
  1371. type: "point-3d",
  1372. symbolLayers: [{
  1373. type: "icon",
  1374. resource: {
  1375. href: "data:image/png;base64," + symbolJson.imageData
  1376. },
  1377. size: 20,
  1378. outline: {
  1379. color: "white",
  1380. size: 2
  1381. }
  1382. }],
  1383. verticalOffset: verticalOffset,
  1384. callout: {
  1385. type: "line",
  1386. color: "white",
  1387. size: 2,
  1388. border: {
  1389. color: "#40C2B4"
  1390. }
  1391. }
  1392. }
  1393. } else if (symbolJson.style == "esriSMSCircle") {
  1394. feature.symbol = {
  1395. type: "point-3d",
  1396. symbolLayers: [{
  1397. type: "icon",
  1398. resource: {
  1399. primitive: "circle"
  1400. },
  1401. size: symbolJson.size * 2,
  1402. material: {
  1403. color: symbolJson.color
  1404. },
  1405. outline: {
  1406. color: symbolJson.outline.color,
  1407. size: symbolJson.outline.size
  1408. }
  1409. }],
  1410. verticalOffset: verticalOffset,
  1411. callout: {
  1412. type: "line",
  1413. color: "white",
  1414. size: 2,
  1415. border: {
  1416. color: "#40C2B4"
  1417. }
  1418. }
  1419. }
  1420. }
  1421. }
  1422. feature.geometry.spatialReference = m_view.spatialReference;
  1423. var popupTemplate = {
  1424. title: "资源信息",
  1425. content: openInfoWin(feature.attributes)
  1426. };
  1427. feature.popupTemplate = popupTemplate;
  1428. var list = {
  1429. "名称": feature.attributes[layerStr],
  1430. "几何": feature
  1431. };
  1432. queryList.push(list);
  1433. return feature
  1434. });
  1435. GraphicsLayer_myLayer.addMany(peakResults);
  1436. m_view.goTo(peakResults);
  1437. dom.byId("printResults").innerHTML = "资产数:<a onclick='openResultTable()'> " + peakResults.length + "</a>"
  1438. }
  1439. function promiseRejected(err) {
  1440. console.error("错误信息: ", err.message)
  1441. }
  1442. })
  1443. }
  1444. function openResultTable() {
  1445. document.getElementById("resultList").style.display = "";
  1446. dyCretateTableByArray("resultListTable", queryList, ["名称"], ["名称"], false)
  1447. }
  1448. function closeResultList() {
  1449. document.getElementById("resultList").style.display = "none"
  1450. }
  1451. function openInfoWin(att) {
  1452. var str = "";
  1453. switch (select_zylx.value) {
  1454. case "CORP":
  1455. {
  1456. str = quickQueryAttributesToHTMLStr(att);
  1457. break
  1458. }
  1459. case "ETPS":
  1460. {
  1461. str = quickQueryAttributesToHTMLStr(att);
  1462. break
  1463. }
  1464. case "PE":
  1465. {
  1466. str = quickQueryAttributesToHTMLStr(att);
  1467. break
  1468. }
  1469. case "PARK":
  1470. {
  1471. str = quickQueryIFrameToHTMLStr(att);
  1472. break
  1473. }
  1474. case "BUILDING":
  1475. {
  1476. str = quickQueryIFrameToHTMLStr(att);
  1477. break
  1478. }
  1479. case "YDYZ":
  1480. {
  1481. str = quickQueryAttributesToHTMLStr(att);
  1482. break
  1483. }
  1484. }
  1485. return str
  1486. }
  1487. function quickQueryAttributesToHTMLStr(att) {
  1488. var arList = [];
  1489. var linkURL = "";
  1490. var id;
  1491. var username;
  1492. var pwd;
  1493. switch (select_zylx.value) {
  1494. case "CORP":
  1495. {
  1496. arList = [{
  1497. cname: "CORP_NAME",
  1498. showname: "组织名称"
  1499. },
  1500. {
  1501. cname: "ADDRESS",
  1502. showname: "地址"
  1503. }];
  1504. id = String(att.CORP_INFO_ID);
  1505. username = "wdzc";
  1506. pwd = "68cf63c62bc68d71fc41c028375e2f6e";
  1507. linkURL = "http://10.214.3.195:8001/coop/syn/detail_register_view_out?ifEncrypt=0&userName=" + username + "&passWord=" + pwd + "&entyId=" + id + "&type=06";
  1508. break
  1509. }
  1510. case "ETPS":
  1511. {
  1512. arList = [{
  1513. cname: "UNISC_ID",
  1514. showname: "统一社会信用代码"
  1515. },
  1516. {
  1517. cname: "REG_NO",
  1518. showname: "注册号"
  1519. },
  1520. {
  1521. cname: "ETPS_NAME",
  1522. showname: "企业名称"
  1523. },
  1524. {
  1525. cname: "ADDRESS",
  1526. showname: "住所"
  1527. }];
  1528. id = String(att.ETPS_ID);
  1529. username = "wdzc";
  1530. pwd = "68cf63c62bc68d71fc41c028375e2f6e";
  1531. linkURL = "http://10.214.3.195:8001/coop/syn/detail_register_view_out?ifEncrypt=0&userName=" + username + "&passWord=" + pwd + "&entyId=" + id + "&type=02";
  1532. break
  1533. }
  1534. case "PE":
  1535. {
  1536. arList = [{
  1537. cname: "UNISC_ID",
  1538. showname: "统一社会信用代码"
  1539. },
  1540. {
  1541. cname: "REG_NO",
  1542. showname: "注册号"
  1543. },
  1544. {
  1545. cname: "NAME",
  1546. showname: "个体名称"
  1547. },
  1548. {
  1549. cname: "ADDRESS",
  1550. showname: "地址"
  1551. }];
  1552. id = String(att.PE_ID);
  1553. username = "wdzc";
  1554. pwd = "68cf63c62bc68d71fc41c028375e2f6e";
  1555. linkURL = "http://10.214.3.195:8001/coop/syn/detail_register_view_out?ifEncrypt=0&userName=" + username + "&passWord=" + pwd + "&entyId=" + id + "&type=05";
  1556. break
  1557. }
  1558. case "YDYZ":
  1559. {
  1560. arList = [{
  1561. cname: "MDNAME",
  1562. showname: "门店名称"
  1563. },
  1564. {
  1565. cname: "ADDRESS",
  1566. showname: "详细地址"
  1567. },
  1568. {
  1569. cname: "STREET",
  1570. showname: "街道"
  1571. },
  1572. {
  1573. cname: "ROAD",
  1574. showname: "道路"
  1575. },
  1576. {
  1577. cname: "JYZLENUMITEM",
  1578. showname: "经营种类"
  1579. },
  1580. {
  1581. cname: "JYZL",
  1582. showname: "经营种类(其他)"
  1583. },
  1584. {
  1585. cname: "FW_SX",
  1586. showname: "房屋属性"
  1587. },
  1588. {
  1589. cname: "MZDW_BZ",
  1590. showname: "备注(基本信息)"
  1591. },
  1592. {
  1593. cname: "ZZ_QK",
  1594. showname: "证照情况"
  1595. },
  1596. {
  1597. cname: "JYZ",
  1598. showname: "经营者"
  1599. },
  1600. {
  1601. cname: "JYZ_IDCARD",
  1602. showname: "身份证(经营者)"
  1603. },
  1604. {
  1605. cname: "JYZ_LXDZ",
  1606. showname: "联系地址(经营者)"
  1607. },
  1608. {
  1609. cname: "JYZ_JG",
  1610. showname: "籍贯(经营者)"
  1611. },
  1612. {
  1613. cname: "JYZ_ZZDZ",
  1614. showname: "暂住地址(经营者)"
  1615. },
  1616. {
  1617. cname: "ZZ_BZ",
  1618. showname: "备注(证照情况)"
  1619. },
  1620. {
  1621. cname: "FD_NAME",
  1622. showname: "房东姓名/单位"
  1623. },
  1624. {
  1625. cname: "FD_JG",
  1626. showname: "籍贯(房东)"
  1627. },
  1628. {
  1629. cname: "FD_LXDZ",
  1630. showname: "联系地址(房东)"
  1631. },
  1632. {
  1633. cname: "FD_LXFS",
  1634. showname: "联系方式(房东)"
  1635. },
  1636. {
  1637. cname: "FD_BZ",
  1638. showname: "备注(房东)"
  1639. },
  1640. {
  1641. cname: "JYZ_LXFS",
  1642. showname: "联系方式(经营者)"
  1643. },
  1644. {
  1645. cname: "FW_BZ",
  1646. showname: "备注(房屋)"
  1647. },
  1648. {
  1649. cname: "JYMJ",
  1650. showname: "经营面积"
  1651. },
  1652. {
  1653. cname: "QT_ZRDY",
  1654. showname: "责任队员"
  1655. },
  1656. {
  1657. cname: "ORGAN",
  1658. showname: "部门"
  1659. },
  1660. {
  1661. cname: "QT_SSGD",
  1662. showname: "所属岗段"
  1663. },
  1664. {
  1665. cname: "JW_LD",
  1666. showname: "居委领导"
  1667. },
  1668. {
  1669. cname: "ROADTYPE",
  1670. showname: "道路类型"
  1671. },
  1672. {
  1673. cname: "NUM",
  1674. showname: "门牌号"
  1675. },
  1676. {
  1677. cname: "GRIDCENTER",
  1678. showname: "网格中心"
  1679. },
  1680. {
  1681. cname: "QT_WG",
  1682. showname: "网格"
  1683. },
  1684. {
  1685. cname: "ZZ_SX",
  1686. showname: "证照属性"
  1687. },
  1688. {
  1689. cname: "JW_NAME",
  1690. showname: "居委名称"
  1691. },
  1692. {
  1693. cname: "JW_LXDH",
  1694. showname: "联系电话(居委)"
  1695. },
  1696. {
  1697. cname: "ZXZTSJ",
  1698. showname: "注销状态时间"
  1699. },
  1700. {
  1701. cname: "CFAJH",
  1702. showname: "曾经是否处罚过"
  1703. },
  1704. {
  1705. cname: "JE",
  1706. showname: "金额(处罚)"
  1707. },
  1708. {
  1709. cname: "OPTIME",
  1710. showname: "操作时间"
  1711. },
  1712. {
  1713. cname: "ISZY",
  1714. showname: "是否重要"
  1715. },
  1716. {
  1717. cname: "QT_LXFS",
  1718. showname: "联系方式"
  1719. },
  1720. {
  1721. cname: "OPUSER",
  1722. showname: "操作人"
  1723. },
  1724. {
  1725. cname: "JYZ_BZ",
  1726. showname: "备注"
  1727. },
  1728. {
  1729. cname: "ZXZT",
  1730. showname: "注销状态"
  1731. },
  1732. {
  1733. cname: "BZ",
  1734. showname: "备注"
  1735. },
  1736. {
  1737. cname: "LONG1",
  1738. showname: "经度gps"
  1739. },
  1740. {
  1741. cname: "LAT",
  1742. showname: "纬度gps"
  1743. }];
  1744. id = String(att.ROWGUID);
  1745. username = "wdzc";
  1746. pwd = "68cf63c62bc68d71fc41c028375e2f6e";
  1747. linkURL = "http://10.214.3.195:8001/coop/syn/detail_register_view_out?ifEncrypt=0&userName=" + username + "&passWord=" + pwd + "&entyId=" + id + "&type=05";
  1748. break
  1749. }
  1750. }
  1751. var str = "";
  1752. for (var name in att) {
  1753. for (var i = 0; i < arList.length; i++) {
  1754. if (name == arList[i].cname) {
  1755. str += arList[i].showname + ":" + att[name] + "<br>"
  1756. }
  1757. }
  1758. }
  1759. str += "<br><a href='" + linkURL + "' target='blank'>[点击详情信息]</a>";
  1760. return str
  1761. }
  1762. function quickQueryIFrameToHTMLStr(att) {
  1763. var sourceid = String(att.主键);
  1764. var url = "";
  1765. switch (select_zylx.value) {
  1766. case "PARK":
  1767. {
  1768. url = "http://10.214.4.162:8080/parkms/tj/parksysSuperviseCD_SSLDL.action?systemsign=408080a758f26bb00158f26f13f30001&is_Park=1&buildingInfosId=" + sourceid;
  1769. break
  1770. }
  1771. case "BUILDING":
  1772. {
  1773. url = "http://10.214.4.162:8080/parkms/tj/parksysSuperviseCD_SSLDL.action?systemsign=408080a758f26bb00158f26f13f30001&is_Park=2&buildingInfosId=" + sourceid;
  1774. break
  1775. }
  1776. }
  1777. var str = " <div style='width:600px;height:500px;'><iframe src='" + url + "' width='100%' height='100%' frameborder='1' scrolling='yes'></iframe></div>";
  1778. return str
  1779. }
  1780. function openQuery() {
  1781. document.getElementById("query").style.display = "";
  1782. document.getElementById("queryReult1").style.display = "";
  1783. document.getElementById("queryReult2").style.display = "none";
  1784. document.getElementById("return").style.display = "none";
  1785. document.getElementById("barcon1").style.display = "";
  1786. document.getElementById("barcon2").style.display = "none";
  1787. document.getElementById("name").value = "";
  1788. document.getElementById("queryTable1").innerHTML = "";
  1789. document.getElementById("barcon1").innerHTML = "";
  1790. createLayerSelect("quertLayerSelect")
  1791. }
  1792. function closeQuery() {
  1793. document.getElementById("query").style.display = "none"
  1794. }
  1795. function returnQueryList() {
  1796. document.getElementById("queryReult1").style.display = "";
  1797. document.getElementById("queryReult2").style.display = "none";
  1798. document.getElementById("return").style.display = "none";
  1799. document.getElementById("barcon1").style.display = "";
  1800. document.getElementById("barcon2").style.display = "none"
  1801. }
  1802. function queryByWhere() {
  1803. document.getElementById("queryReult1").style.display = "";
  1804. document.getElementById("queryReult2").style.display = "none";
  1805. var name = document.getElementById("name").value;
  1806. if (name == "") {
  1807. alert("请输入查询内容");
  1808. return
  1809. }
  1810. queryExtent = null;
  1811. btClear_Click();
  1812. queryAll()
  1813. }
  1814. function newOpenLayer(layerName, type, name, isGoTo, isOpen) {
  1815. if (type == 1) {
  1816. type = "街道乡镇";
  1817. }
  1818. else if (type == 2) {
  1819. type = "区县边界";
  1820. }
  1821. else {
  1822. return;
  1823. }
  1824. var layerId = GetFeatureLayerIdbyName(type);
  1825. var where = "";
  1826. var attributename = "";
  1827. var layerCondition = "";
  1828. if (type == "街道乡镇") {
  1829. where = "街道名称 = '" + name + "'";
  1830. attributename = "街道代码";
  1831. layerCondition = "街道代码";
  1832. }
  1833. else {
  1834. where = "区县名称 = '" + name + "'";
  1835. attributename = "区县代码";
  1836. layerCondition = "区代码";
  1837. }
  1838. if (layerId == -1) {
  1839. window.parent.postMessage(
  1840. {
  1841. method: "newOpenLayer",
  1842. data: ["参数type填写错误"]
  1843. },
  1844. '*'
  1845. );
  1846. }
  1847. else {
  1848. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom"],
  1849. function (QueryTask, Query, FeatureLayer, arrayUtils, dom) {
  1850. var urlI = dyLayer.url + "/" + layerId;
  1851. var restUrl = urlI + "?f=pjson";
  1852. var xmlHttpRest = GetXmlHttpObject();
  1853. xmlHttpRest.open("GET", restUrl, true);
  1854. xmlHttpRest.send();
  1855. xmlHttpRest.onreadystatechange = function () {
  1856. if (xmlHttpRest.readyState == 4) {
  1857. var responseText = xmlHttpRest.responseText;
  1858. var LayerJsonData = JSON.parse(responseText);
  1859. var qTask = new QueryTask({
  1860. url: urlI
  1861. });
  1862. var params = new Query({
  1863. geometry: queryExtent,
  1864. returnGeometry: true,
  1865. outFields: ["*"]
  1866. });
  1867. //params.spatialRelationship = "intersects";
  1868. //params.geometry = geo || null;
  1869. params.where = where;
  1870. qTask.execute(params).then(getResults).otherwise(promiseRejected);
  1871. function getResults(response) {
  1872. if (response.features.length == 0) {
  1873. window.parent.postMessage(
  1874. {
  1875. method: "newOpenLayer",
  1876. data: ["参数name填写错误"]
  1877. },
  1878. '*'
  1879. );
  1880. return;
  1881. }
  1882. var feature = response.features[0];
  1883. var attributewhere = response.features[0].attributes[attributename];
  1884. var layerwhere = layerCondition + "='" + attributewhere + "'";
  1885. // var symbolJson = LayerJsonData.drawingInfo.renderer;
  1886. newOpenLayerbyWhere(layerName, isOpen, layerCondition, attributewhere);
  1887. if (isGoTo) {
  1888. m_view.goTo(feature.geometry);
  1889. }
  1890. }
  1891. function promiseRejected(err) {
  1892. //console.error("错误信息: ", err.message);
  1893. }
  1894. }
  1895. };
  1896. });
  1897. }
  1898. }
  1899. function newOpenLayerbyWhere(layerName, layerVisible, layerCondition, attributewhere) {
  1900. if (!layerVisible) {
  1901. var layerId = GetFeatureLayerIdbyName(layerName);
  1902. // var qxlayerId = GetQXFeatureLayerIdbyName(layerName);
  1903. for (var i = 0; i < m_map.layers.length; i++) {
  1904. var BaseLayer = m_map.layers.getItemAt(i);
  1905. if (BaseLayer.declaredClass == "esri.layers.FeatureLayer") {
  1906. var layer = m_map.layers.getItemAt(i);
  1907. if (layer.id == layerId) {
  1908. // m_map.layers.getItemAt(i).renderer = layerRenerer;
  1909. m_map.layers.getItemAt(i).visible = layerVisible;
  1910. m_map.remove(m_map.layers.getItemAt(i));
  1911. }
  1912. if (layer.id == layerId + "_qx") {
  1913. // m_map.layers.getItemAt(i).renderer = layerRenerer;
  1914. m_map.layers.getItemAt(i).visible = layerVisible;
  1915. m_map.remove(m_map.layers.getItemAt(i));
  1916. }
  1917. }
  1918. }
  1919. return;
  1920. }
  1921. require(["esri/layers/FeatureLayer", "dojo/on"], function (FeatureLayer, on) {
  1922. var serverUrl = GetConfigDataByName("MYFeatureLayerLayer");
  1923. var layerId = GetFeatureLayerIdbyName(layerName);
  1924. var qxserverUrl = GetConfigDataByName("MYQXFeatureLayer");
  1925. var qxlayerId = GetQXFeatureLayerIdbyName(layerName);
  1926. var isnewFeatureLayer = true;
  1927. for (var i = 0; i < m_map.layers.length; i++) {
  1928. var BaseLayer = m_map.layers.getItemAt(i);
  1929. if (BaseLayer.declaredClass == "esri.layers.FeatureLayer") {
  1930. var layer = m_map.layers.getItemAt(i);
  1931. if (layer.id == layerId) {
  1932. // m_map.layers.getItemAt(i).renderer = layerRenerer;
  1933. m_map.layers.getItemAt(i).visible = layerVisible;
  1934. isnewFeatureLayer = false;
  1935. }
  1936. if (layer.id == layerId + "_qx") {
  1937. m_map.layers.getItemAt(i).visible = layerVisible;
  1938. isnewFeatureLayer = false;
  1939. }
  1940. }
  1941. }
  1942. if (isnewFeatureLayer) {
  1943. var dyLayer = new FeatureLayer({
  1944. url: serverUrl + "/" + layerId,
  1945. id: layerId,
  1946. definitionExpression: layerCondition + "=" + attributewhere
  1947. });
  1948. var qxdyLayer;
  1949. if (qxlayerId != -1) {
  1950. qxdyLayer = new FeatureLayer({
  1951. url: qxserverUrl + "/" + qxlayerId,
  1952. id: layerId + "_qx",
  1953. definitionExpression: layerCondition + "=" + attributewhere
  1954. });
  1955. qxdyLayer.visible = layerVisible;
  1956. qxdyLayer.outFields = ["*"];
  1957. m_map.add(qxdyLayer, 1);
  1958. }
  1959. var clusterConfig = {
  1960. type: "cluster",
  1961. clusterRadius: "50px"
  1962. };
  1963. // dyLayer.renderer = layerRenerer;
  1964. // dyLayer.featureReduction = clusterConfig;
  1965. dyLayer.visible = layerVisible;
  1966. dyLayer.outFields = ["*"];
  1967. m_map.add(dyLayer, 2);
  1968. }
  1969. });
  1970. // require([
  1971. // "esri/layers/FeatureLayer",
  1972. // "dojo/on"
  1973. // ], function ( FeatureLayer,on) {
  1974. // var layerId = GetFeatureLayerIdbyName(layerName);
  1975. // var urlI = dyLayer.url + "/" + layerId;
  1976. // var restUrl = urlI + "?f=pjson";
  1977. // var xmlHttpRest = GetXmlHttpObject();
  1978. // xmlHttpRest.open("GET", restUrl, true);
  1979. // xmlHttpRest.send();
  1980. // xmlHttpRest.onreadystatechange = function() {
  1981. // if (xmlHttpRest.readyState == 4) {
  1982. // var responseText = xmlHttpRest.responseText;
  1983. // var LayerJsonData = JSON.parse(responseText);
  1984. // var renderer = LayerJsonData.drawingInfo.renderer;
  1985. // var newsymbol;
  1986. // var symbol = LayerJsonData.drawingInfo.renderer.symbol;
  1987. // if (LayerJsonData) {
  1988. // if (symbol.type == "esriSFS") {
  1989. // newsymbol = {
  1990. // type: "simple-fill",
  1991. // style: changeStyle(symbol.style),
  1992. // color: symbol.color,
  1993. // outline: {
  1994. // style: changeStyle(symbol.outline.style),
  1995. // color: symbol.outline.color,
  1996. // width: symbol.outline.width
  1997. // }
  1998. // }
  1999. // } else if (symbol.type == "esriPMS") {
  2000. // newsymbol = {
  2001. // type: "picture-marker",
  2002. // url: "data:image/png;base64," + symbol.imageData,
  2003. // width: symbol.width,
  2004. // height: symbol.height
  2005. // }
  2006. // } else if (symbol.type == "esriSMS") {
  2007. // newsymbol = {
  2008. // type: "simple-marker",
  2009. // size: symbol.size,
  2010. // color: symbol.color,
  2011. // outline: symbol.outline
  2012. // }
  2013. // }
  2014. // }
  2015. //
  2016. //
  2017. // var layerRenerer = {
  2018. // type: "unique-value",
  2019. // field: layerCondition,
  2020. // uniqueValueInfos: [{
  2021. // value: attributewhere,
  2022. // symbol: newsymbol
  2023. // }]
  2024. // };
  2025. //
  2026. //
  2027. // var serverUrl = GetConfigDataByName("MYFeatureLayerLayer");
  2028. //
  2029. // var isnewFeatureLayer = true;
  2030. // for (var i = 0; i < m_map.layers.length; i++) {
  2031. // var BaseLayer = m_map.layers.getItemAt(i);
  2032. // if (BaseLayer.declaredClass == "esri.layers.FeatureLayer") {
  2033. // var layer = m_map.layers.getItemAt(i);
  2034. // if (layer.id == layerId) {
  2035. // m_map.layers.getItemAt(i).renderer = layerRenerer;
  2036. // m_map.layers.getItemAt(i).visible = layerVisible;
  2037. // isnewFeatureLayer = false;
  2038. // break;
  2039. // }
  2040. // }
  2041. // }
  2042. // if(isnewFeatureLayer){
  2043. // var dyLayer = new FeatureLayer({
  2044. // url: serverUrl+"/"+layerId,
  2045. // id: layerId,
  2046. // definitionExpression: layerCondition+"="+attributewhere
  2047. // });
  2048. // var clusterConfig={
  2049. // type: "cluster",
  2050. // clusterRadius: "50px"
  2051. // };
  2052. // // dyLayer.renderer = layerRenerer;
  2053. // dyLayer.visible = layerVisible;
  2054. // dyLayer.outFields = ["*"];
  2055. // m_map.add(dyLayer,1);
  2056. // dyLayer.featureReduction = clusterConfig;
  2057. // }
  2058. // }
  2059. // };
  2060. // });
  2061. }
  2062. function setLayerCluster(layerName, iscluster) {
  2063. var layerId = GetFeatureLayerIdbyName(layerName);
  2064. for (var i = 0; i < m_map.layers.length; i++) {
  2065. var BaseLayer = m_map.layers.getItemAt(i);
  2066. if (BaseLayer.declaredClass == "esri.layers.FeatureLayer") {
  2067. var layer = m_map.layers.getItemAt(i);
  2068. if (layer.id == layerId) {
  2069. // m_map.layers.getItemAt(i).visible = layerVisible;
  2070. if (iscluster) {
  2071. m_map.layers.getItemAt(i).featureReduction = {
  2072. type: "cluster",
  2073. clusterRadius: "50px"
  2074. };
  2075. }
  2076. else {
  2077. m_map.layers.getItemAt(i).featureReduction = null;
  2078. }
  2079. break;
  2080. }
  2081. }
  2082. }
  2083. }
  2084. function newQuerybyWhereStr(whereStr, layerName, url, geo, isshow, isGoTo) {
  2085. if (whereStr == "")
  2086. whereStr = "1=1";
  2087. if (isshow == undefined || isshow == null)
  2088. isshow = true;
  2089. if (isGoTo == undefined || isGoTo == null)
  2090. isGoTo = true;
  2091. var layerId = GetFeatureLayerIdbyName(layerName);
  2092. if (layerId == -1) {
  2093. // alert("没有此图层");
  2094. window.parent.postMessage(
  2095. {
  2096. method: "queryByGeometryAndLayer",
  2097. data: ["没有此图层"]
  2098. },
  2099. '*'
  2100. );
  2101. } else {
  2102. newQueryGraphicByDylayer(layerId, whereStr, url, geo, isshow, isGoTo);
  2103. }
  2104. }
  2105. function newQueryGraphicByDylayer(layerId, whereStr, url, geo, isshow, isGoTo) {
  2106. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom"],
  2107. function (QueryTask, Query, FeatureLayer, arrayUtils, dom) {
  2108. btClear_Click();
  2109. var urlI = dyLayer.url + "/" + layerId;
  2110. var restUrl = urlI + "?f=pjson";
  2111. var xmlHttpRest = GetXmlHttpObject();
  2112. xmlHttpRest.open("GET", restUrl, true);
  2113. xmlHttpRest.send();
  2114. xmlHttpRest.onreadystatechange = function () {
  2115. var responseText = xmlHttpRest.responseText;
  2116. if (xmlHttpRest.readyState == 4) {
  2117. var LayerJsonData = JSON.parse(responseText);
  2118. var qTask = new QueryTask({
  2119. url: urlI
  2120. });
  2121. var params = new Query({
  2122. geometry: queryExtent,
  2123. returnGeometry: true,
  2124. outFields: ["*"]
  2125. });
  2126. params.spatialRelationship = "intersects";
  2127. params.geometry = geo || null;
  2128. params.where = whereStr;
  2129. qTask.execute(params).then(getResults).otherwise(promiseRejected);
  2130. function getResults(response) {
  2131. if (response.features.length == 0) {
  2132. window.parent.postMessage(
  2133. {
  2134. method: "queryByGeometryAndLayer",
  2135. data: []
  2136. },
  2137. '*'
  2138. );
  2139. return;
  2140. }
  2141. var attributesArr = [];
  2142. var peakResults = arrayUtils.map(response.features,
  2143. function (feature) {
  2144. var obj = LayerJsonData;
  2145. attributesArr.push(feature.attributes);
  2146. var symbolJson = obj.drawingInfo.renderer.symbol;
  2147. if (currentMapMode == "2D") {
  2148. if (symbolJson) {
  2149. if (symbolJson.type == "esriSFS") {
  2150. feature.symbol = {
  2151. type: "simple-fill",
  2152. style: changeStyle(symbolJson.style),
  2153. color: symbolJson.color,
  2154. outline: {
  2155. style: changeStyle(symbolJson.outline.style),
  2156. color: symbolJson.outline.color,
  2157. width: symbolJson.outline.width
  2158. }
  2159. }
  2160. } else if (symbolJson.type == "esriPMS") {
  2161. feature.symbol = {
  2162. type: "picture-marker",
  2163. url: "data:image/png;base64," + symbolJson.imageData,
  2164. width: symbolJson.width,
  2165. height: symbolJson.height
  2166. }
  2167. } else if (symbolJson.type == "esriSMS") {
  2168. feature.symbol = {
  2169. type: "simple-marker",
  2170. size: symbolJson.size,
  2171. color: symbolJson.color,
  2172. outline: symbolJson.outline
  2173. }
  2174. }
  2175. } else {
  2176. feature.symbol = {
  2177. type: "simple-marker",
  2178. color: rgba(255, 0, 0, 1),
  2179. outline: {
  2180. color: [0, 0, 0, 1],
  2181. width: 1
  2182. }
  2183. }
  2184. }
  2185. } else {
  2186. var verticalOffset = {
  2187. screenLength: 40,
  2188. maxWorldLength: 200,
  2189. minWorldLength: 35
  2190. };
  2191. if (symbolJson.type == "esriSFS") {
  2192. feature.symbol = {
  2193. type: "polygon-3d",
  2194. symbolLayers: [{
  2195. type: "fill",
  2196. material: {
  2197. color: symbolJson.color
  2198. }
  2199. }],
  2200. outline: {
  2201. color: symbolJson.outline.color,
  2202. size: symbolJson.outline.size
  2203. }
  2204. }
  2205. } else if (symbolJson.type == "esriPMS") {
  2206. feature.symbol = {
  2207. type: "point-3d",
  2208. symbolLayers: [{
  2209. type: "icon",
  2210. resource: {
  2211. href: "data:image/png;base64," + symbolJson.imageData
  2212. },
  2213. size: 20,
  2214. outline: {
  2215. color: "white",
  2216. size: 2
  2217. }
  2218. }],
  2219. verticalOffset: verticalOffset,
  2220. callout: {
  2221. type: "line",
  2222. color: "white",
  2223. size: 2,
  2224. border: {
  2225. color: "#40C2B4"
  2226. }
  2227. }
  2228. }
  2229. } else if (symbolJson.style == "esriSMSCircle") {
  2230. feature.symbol = {
  2231. type: "point-3d",
  2232. symbolLayers: [{
  2233. type: "icon",
  2234. resource: {
  2235. primitive: "circle"
  2236. },
  2237. size: symbolJson.size * 2,
  2238. material: {
  2239. color: symbolJson.color
  2240. },
  2241. outline: {
  2242. color: symbolJson.outline.color,
  2243. size: symbolJson.outline.size
  2244. }
  2245. }],
  2246. verticalOffset: verticalOffset,
  2247. callout: {
  2248. type: "line",
  2249. color: "white",
  2250. size: 2,
  2251. border: {
  2252. color: "#40C2B4"
  2253. }
  2254. }
  2255. }
  2256. }
  2257. }
  2258. feature.geometry.spatialReference = m_view.spatialReference;
  2259. var popupTemplate = {
  2260. title: "详细信息",
  2261. content: attributesToHTMLStr(feature.attributes)
  2262. };
  2263. // feature.popupTemplate = popupTemplate;
  2264. return feature
  2265. });
  2266. if (isshow) {
  2267. GraphicsLayer_myLayer.addMany(peakResults);
  2268. if (isGoTo) {
  2269. m_view.goTo(peakResults);
  2270. }
  2271. }
  2272. window.parent.postMessage(
  2273. {
  2274. method: "queryByGeometryAndLayer",
  2275. data: [attributesArr]
  2276. },
  2277. '*'
  2278. );
  2279. }
  2280. function promiseRejected(err) {
  2281. console.error("错误信息: ", err.message);
  2282. }
  2283. }
  2284. }
  2285. });
  2286. }
  2287. function querybyWhereStr(whereStr, layerName) {
  2288. if (whereStr == "") {
  2289. whereStr = " 1=1 "
  2290. }
  2291. var layerId = GetFeatureLayerIdbyName(layerName);
  2292. if (layerId == -1) {
  2293. alert("没有此图层")
  2294. } else {
  2295. queryGraphicByDylayer(layerId, whereStr, "http://10.101.35.46:6080/arcgis/rest/services/WJJBH/FeatureServer")
  2296. }
  2297. }
  2298. function GetFeatureLayerIdbyName(layerName) {
  2299. var layerId = -1;
  2300. if (extraLayerJsonData != "") {
  2301. var layers = extraLayerJsonData.layers;
  2302. if (layers.length > 0) {
  2303. for (var i = 0; i < layers.length; i++) {
  2304. // if (layers[i].name == layerName && layers[i].subLayerIds == null) {
  2305. // layerId = layers[i].id;
  2306. // break;
  2307. // }
  2308. if (layers[i].name == layerName) {
  2309. if (layers[i].subLayerIds == null) {
  2310. layerId = layers[i].id;
  2311. }
  2312. else {
  2313. if (layers[i].subLayerIds.length == 1)
  2314. layerId = layers[i].subLayerIds[0];
  2315. else
  2316. layerId = layers[i].subLayerIds[1];
  2317. }
  2318. break;
  2319. }
  2320. }
  2321. }
  2322. }
  2323. return layerId;
  2324. }
  2325. function GetQXFeatureLayerIdbyName(layerName) {
  2326. var layerId = -1;
  2327. if (qxLayerJsonData != "") {
  2328. var layers = qxLayerJsonData.layers;
  2329. if (layers.length > 0) {
  2330. for (var i = 0; i < layers.length; i++) {
  2331. // if (layers[i].name == layerName && layers[i].subLayerIds == null) {
  2332. // layerId = layers[i].id;
  2333. // break;
  2334. // }
  2335. if (layers[i].name == layerName) {
  2336. if (layers[i].subLayerIds == null) {
  2337. layerId = layers[i].id;
  2338. }
  2339. else {
  2340. if (layers[i].subLayerIds.length == 1)
  2341. layerId = layers[i].subLayerIds[0];
  2342. else
  2343. layerId = layers[i].subLayerIds[1];
  2344. }
  2345. break;
  2346. }
  2347. }
  2348. }
  2349. }
  2350. return layerId;
  2351. }
  2352. function queryAll() {
  2353. queryList.splice(0, queryList.length);
  2354. if (currentMapMode == "3D") {
  2355. var select = document.getElementById("quertLayerSelect");
  2356. queryRecursive(select.value)
  2357. } else {
  2358. queryRecursive(0);
  2359. progress("0%")
  2360. }
  2361. }
  2362. function queryRecursive(j) {
  2363. var layerInfo = GetDynamicServiceLayer();
  2364. if (currentMapMode == "2D") {
  2365. if (j == Math.ceil(layerInfo.length / 4)) {
  2366. progress("30%")
  2367. }
  2368. if (j === Math.ceil(layerInfo.length / 2)) {
  2369. progress("60%")
  2370. }
  2371. if (j === Math.ceil(layerInfo.length * 3 / 4)) {
  2372. progress("90%")
  2373. }
  2374. if (j >= layerInfo.length) {
  2375. progress("100%")
  2376. }
  2377. }
  2378. var name = document.getElementById("name").value;
  2379. if (j == layerInfo.length) {
  2380. if (queryList.length == 0) {
  2381. alert("没有结果");
  2382. return
  2383. }
  2384. m_view.goTo(GraphicsLayer_myLayer.graphics);
  2385. dyCretateTableByArray("queryTable1", queryList, ["名称", "图层名"], ["名称", "图层名"], false, true);
  2386. goPage(1, "queryTable1");
  2387. return
  2388. }
  2389. var layerField = "";
  2390. var xmlDoc1 = xmlUtil.loadXmlFromFile("config/layerQueryName.xml");
  2391. var layerXml = xmlDoc1.getElementsByTagName(GetLayerNamebyId(j));
  2392. var mapNodes = layerXml[0].childNodes;
  2393. for (var i = 0; i < mapNodes.length; i++) {
  2394. if (xmlUtil.getNodeTagName(mapNodes[i]) == "name") {
  2395. layerField = xmlUtil.getNodeValue(mapNodes[i])
  2396. }
  2397. }
  2398. if (j < layerInfo.length) {
  2399. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "esri/Graphic", "dojo/dom"],
  2400. function (QueryTask, Query, FeatureLayer, arrayUtils, Graphic, dom) {
  2401. var urlI = dyLayer.url + "/" + j;
  2402. var qTask = new QueryTask({
  2403. url: urlI
  2404. });
  2405. var params = new Query({
  2406. geometry: queryExtent,
  2407. returnGeometry: true,
  2408. outFields: ["*"]
  2409. });
  2410. var where;
  2411. if (name == null || name == "") {
  2412. where = "1=1"
  2413. } else {
  2414. where = layerField + " like '%" + name + "%' "
  2415. }
  2416. params.where = where;
  2417. qTask.execute(params).then(getResults).otherwise(promiseRejected);
  2418. function getResults(response) {
  2419. var peakResults = arrayUtils.map(response.features,
  2420. function (feature) {
  2421. var obj = eval("(" + symble[j] + ")");
  2422. var symbolJson = obj.drawingInfo.renderer.symbol;
  2423. if (currentMapMode == "2D") {
  2424. if (symbolJson.type == "esriSFS") {
  2425. feature.symbol = {
  2426. type: "simple-fill",
  2427. style: changeStyle(symbolJson.style),
  2428. color: symbolJson.color,
  2429. outline: {
  2430. style: changeStyle(symbolJson.outline.style),
  2431. color: symbolJson.outline.color,
  2432. width: symbolJson.outline.width
  2433. }
  2434. }
  2435. } else if (symbolJson.type == "esriPMS") {
  2436. feature.symbol = {
  2437. type: "picture-marker",
  2438. url: "data:image/png;base64," + symbolJson.imageData,
  2439. width: symbolJson.width,
  2440. height: symbolJson.height
  2441. }
  2442. }
  2443. } else {
  2444. var verticalOffset = {
  2445. screenLength: 40,
  2446. maxWorldLength: 200,
  2447. minWorldLength: 35
  2448. };
  2449. if (symbolJson.type == "esriSFS") {
  2450. for (var i = 0; i < feature.geometry.rings[0].length; i++) {
  2451. feature.geometry.rings[0][i].push(20)
  2452. }
  2453. var polygon = {
  2454. type: "polygon",
  2455. rings: feature.geometry.rings
  2456. };
  2457. var polygonGraphic = new Graphic({
  2458. geometry: polygon
  2459. });
  2460. polygonGraphic.symbol = {
  2461. type: "polygon-3d",
  2462. symbolLayers: [{
  2463. type: "fill",
  2464. material: {
  2465. color: symbolJson.color
  2466. },
  2467. outline: {
  2468. color: symbolJson.outline.color,
  2469. size: symbolJson.outline.size
  2470. }
  2471. }]
  2472. }
  2473. } else if (symbolJson.type == "esriPMS") {
  2474. feature.symbol = {
  2475. type: "point-3d",
  2476. symbolLayers: [{
  2477. type: "icon",
  2478. resource: {
  2479. href: "data:image/png;base64," + symbolJson.imageData
  2480. },
  2481. size: 20,
  2482. outline: {
  2483. color: "white",
  2484. size: 2
  2485. }
  2486. }],
  2487. verticalOffset: verticalOffset,
  2488. callout: {
  2489. type: "line",
  2490. color: "white",
  2491. size: 2,
  2492. border: {
  2493. color: "#40C2B4"
  2494. }
  2495. }
  2496. }
  2497. } else if (symbolJson.style == "esriSMSCircle") {
  2498. feature.symbol = {
  2499. type: "point-3d",
  2500. symbolLayers: [{
  2501. type: "icon",
  2502. resource: {
  2503. primitive: "circle"
  2504. },
  2505. size: symbolJson.size * 2,
  2506. material: {
  2507. color: symbolJson.color
  2508. },
  2509. outline: {
  2510. color: symbolJson.outline.color,
  2511. size: symbolJson.outline.size
  2512. }
  2513. }],
  2514. verticalOffset: verticalOffset,
  2515. callout: {
  2516. type: "line",
  2517. color: "white",
  2518. size: 2,
  2519. border: {
  2520. color: "#40C2B4"
  2521. }
  2522. }
  2523. }
  2524. }
  2525. }
  2526. feature.geometry.spatialReference = m_view.spatialReference;
  2527. var popupTemplate = {
  2528. title: "详细信息",
  2529. content: "所在图层:" + GetLayerNamebyId(j) + "<br>" + attributesToHTMLStr(feature.attributes)
  2530. };
  2531. feature.popupTemplate = popupTemplate;
  2532. var attInfo = [];
  2533. for (var name in feature.attributes) {
  2534. attInfo.push({
  2535. "属性": name,
  2536. "值": feature.attributes[name]
  2537. })
  2538. }
  2539. var list = {
  2540. "名称": feature.attributes[layerField],
  2541. "图层名": GetLayerNamebyId(j),
  2542. "详情": attInfo,
  2543. "几何": feature
  2544. };
  2545. queryList.push(list);
  2546. if (currentMapMode == "3D") {
  2547. if (symbolJson.type == "esriSFS") {
  2548. polygonGraphic.geometry.spatialReference = m_view.spatialReference;
  2549. polygonGraphic.popupTemplate = popupTemplate;
  2550. return polygonGraphic
  2551. }
  2552. }
  2553. return feature
  2554. });
  2555. GraphicsLayer_myLayer.addMany(peakResults);
  2556. if (currentMapMode == "3D") {
  2557. if (queryList.length == 0) {
  2558. alert("没有结果");
  2559. return
  2560. }
  2561. m_view.goTo(GraphicsLayer_myLayer.graphics);
  2562. dyCretateTableByArray("queryTable1", queryList, ["名称", "图层名"], ["名称", "图层名"], false, true);
  2563. goPage(1, "queryTable1")
  2564. } else {
  2565. queryRecursive(j + 1)
  2566. }
  2567. }
  2568. function promiseRejected(err) {
  2569. console.error("图层:" + j + "错误信息: ", err.message)
  2570. }
  2571. })
  2572. }
  2573. }
  2574. function queryBySquare() {
  2575. queryExtent = null;
  2576. require(["esri/Map", "esri/views/MapView", "esri/layers/MapImageLayer", "esri/layers/TileLayer", "esri/geometry/Geometry", "esri/geometry/Extent", "esri/tasks/GeometryService", "esri/layers/GraphicsLayer", "esri/widgets/ScaleBar", "esri/WebMap", "esri/geometry/SpatialReference", "esri/Graphic", "esri/views/2d/draw/Draw", "esri/geometry/Polygon", "esri/geometry/geometryEngine"],
  2577. function (Map, MapView, MapImageLayer, TileLayer, Geometry, Extent, GeometryService, GraphicsLayer, ScaleBar, WebMap, SpatialReference, Graphic, Draw, Polygon, geometryEngine) {
  2578. var action = m_drawtool.create("polygon");
  2579. m_view.focus();
  2580. action.on("vertex-add", drawPolygon);
  2581. action.on("cursor-update", drawPolygon);
  2582. action.on("vertex-remove", drawPolygon);
  2583. action.on("draw-complete", drawPolygonEnd);
  2584. function drawPolygon(evt) {
  2585. var vertices = evt.vertices;
  2586. btClear_Click();
  2587. var polygon = createPolygon(vertices);
  2588. var graphic = createGraphic(polygon);
  2589. GraphicsLayer_DrawLayer.add(graphic);
  2590. queryExtent = polygon
  2591. }
  2592. function drawPolygonEnd(evt) {
  2593. drawPolygon(evt);
  2594. queryAll()
  2595. }
  2596. function createPolygon(vertices) {
  2597. return new Polygon({
  2598. rings: vertices,
  2599. spatialReference: m_view.spatialReference
  2600. })
  2601. }
  2602. function createGraphic(polygon) {
  2603. graphic = new Graphic({
  2604. geometry: polygon,
  2605. symbol: {
  2606. type: "simple-fill",
  2607. color: [178, 102, 234, .8],
  2608. style: "solid",
  2609. outline: {
  2610. color: [255, 255, 255],
  2611. width: 2
  2612. }
  2613. }
  2614. });
  2615. return graphic
  2616. }
  2617. })
  2618. }
  2619. function queryByStreet() {
  2620. document.getElementById("name").value = "";
  2621. queryExtent = null;
  2622. btClear_Click();
  2623. var action = m_drawtool.create("point");
  2624. action.on("draw-complete",
  2625. function (evt) {
  2626. createPointGraphic(evt.coordinates, "街道乡镇")
  2627. })
  2628. }
  2629. function queryByCommittees() {
  2630. document.getElementById("name").value = "";
  2631. queryExtent = null;
  2632. btClear_Click();
  2633. var action = m_drawtool.create("point");
  2634. action.on("draw-complete",
  2635. function (evt) {
  2636. createPointGraphic(evt.coordinates, "村居委会")
  2637. })
  2638. }
  2639. function createPointGraphic(coordinates, layerName) {
  2640. require(["esri/geometry/Point"],
  2641. function (Point) {
  2642. m_view.graphics.removeAll();
  2643. var point = new Point({
  2644. x: coordinates[0],
  2645. y: coordinates[1],
  2646. spatialReference: m_view.spatialReference
  2647. });
  2648. queryExtent = point;
  2649. queryExtentByPoint(layerName)
  2650. })
  2651. }
  2652. function queryExtentByPoint(layerName) {
  2653. var id = GetLayerIdbyName(layerName);
  2654. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom"],
  2655. function (QueryTask, Query, FeatureLayer, arrayUtils, dom) {
  2656. var urlI = dyLayer.url + "/" + id;
  2657. var qTask = new QueryTask({
  2658. url: urlI
  2659. });
  2660. var params = new Query({
  2661. geometry: queryExtent,
  2662. returnGeometry: true,
  2663. outFields: ["*"]
  2664. });
  2665. params.where = "1=1";
  2666. qTask.execute(params).then(getResults).otherwise(promiseRejected);
  2667. function getResults(response) {
  2668. var peakResults = arrayUtils.map(response.features,
  2669. function (feature) {
  2670. feature.geometry.spatialReference = m_view.spatialReference;
  2671. queryExtent = null;
  2672. queryExtent = feature.geometry;
  2673. return feature
  2674. });
  2675. if (peakResults.length == 0) {
  2676. alert("无此范围" + layerName)
  2677. } else {
  2678. queryAll()
  2679. }
  2680. }
  2681. function promiseRejected(err) {
  2682. console.error("错误信息: ", err.message)
  2683. }
  2684. })
  2685. }
  2686. function createLayerSelect(selectId) {
  2687. var select = document.getElementById(selectId);
  2688. select.innerHTML = "";
  2689. var layerInfo;
  2690. layerInfo = GetDynamicServiceLayer();
  2691. if (layerInfo != null) {
  2692. for (var j = layerInfo.length; j > 0; j--) {
  2693. var option = document.createElement("option");
  2694. var currnetLayer = layerInfo.getItemAt(j - 1);
  2695. option.innerHTML = currnetLayer.title;
  2696. option.value = currnetLayer.id;
  2697. select.append(option)
  2698. }
  2699. }
  2700. }
  2701. function openStatistics() {
  2702. document.getElementById("statistics").style.display = "";
  2703. document.getElementById("statistics1").style.display = "";
  2704. document.getElementById("statistics2").style.display = "none";
  2705. document.getElementById("statistics3").style.display = "none";
  2706. document.getElementById("statistics4").style.display = "none";
  2707. createLayerSelect("statistics1LayerSelect");
  2708. createStreetCheck("statistics1CheckTable", "街道乡镇")
  2709. }
  2710. function closeStatistics() {
  2711. document.getElementById("statistics").style.display = "none"
  2712. }
  2713. function returnTostatistic1() {
  2714. document.getElementById("statistics1").style.display = "";
  2715. document.getElementById("statistics2").style.display = "none"
  2716. }
  2717. function returnTostatistic2() {
  2718. document.getElementById("statistics2").style.display = "";
  2719. document.getElementById("statistics3").style.display = "none"
  2720. }
  2721. function returnTostatistic3() {
  2722. document.getElementById("statistics3").style.display = "";
  2723. document.getElementById("statistics4").style.display = "none"
  2724. }
  2725. function createStreetCheck(tableId, layerName) {
  2726. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom"],
  2727. function (QueryTask, Query, FeatureLayer, arrayUtils, dom) {
  2728. var urlI = dyLayer.url + "/" + GetLayerIdbyName(layerName);
  2729. var qTask = new QueryTask({
  2730. url: urlI
  2731. });
  2732. var params = new Query({
  2733. returnGeometry: true,
  2734. outFields: ["*"]
  2735. });
  2736. params.where = "1=1";
  2737. qTask.execute(params).then(getResults).otherwise(promiseRejected);
  2738. function getResults(response) {
  2739. var peakResults = arrayUtils.map(response.features,
  2740. function (feature) {
  2741. return feature
  2742. });
  2743. var tbody = document.getElementById(tableId);
  2744. tbody.innerHTML = "";
  2745. for (var j = 0; j < peakResults.length; j++) {
  2746. if (j % 2 == 1) {
  2747. var tr = document.createElement("tr");
  2748. var td1 = document.createElement("td");
  2749. td1.setAttribute("style", "width:230px;height:30px");
  2750. td1.setAttribute("align", "left");
  2751. var input1 = document.createElement("input");
  2752. input1.setAttribute("type", "checkbox");
  2753. input1.setAttribute("name", "statistics1CheckBox");
  2754. input1.value = peakResults[j - 1].attributes.名称;
  2755. td1.append(input1);
  2756. td1.append(peakResults[j - 1].attributes.名称);
  2757. var td2 = document.createElement("td");
  2758. td2.setAttribute("style", "width:230px;height:30px");
  2759. td2.setAttribute("align", "left");
  2760. var input2 = document.createElement("input");
  2761. input2.setAttribute("type", "checkbox");
  2762. input2.setAttribute("name", "statistics1CheckBox");
  2763. input2.value = peakResults[j].attributes.名称;
  2764. td2.append(input2);
  2765. td2.append(peakResults[j].attributes.名称);
  2766. tr.append(td1);
  2767. tr.append(td2);
  2768. tbody.append(tr)
  2769. } else if (j == peakResults.length - 1) {
  2770. var tr = document.createElement("tr");
  2771. var td1 = document.createElement("td");
  2772. td1.setAttribute("style", "width:230px;height:30px");
  2773. td1.setAttribute("align", "left");
  2774. var input1 = document.createElement("input");
  2775. input1.setAttribute("type", "checkbox");
  2776. input1.setAttribute("name", "statistics1CheckBox");
  2777. input1.value = peakResults[j - 1].attributes.名称;
  2778. td1.append(input1);
  2779. td1.append(peakResults[j - 1].attributes.名称);
  2780. var td2 = document.createElement("td");
  2781. tr.append(td1);
  2782. tr.append(td2);
  2783. tbody.append(tr)
  2784. }
  2785. }
  2786. }
  2787. function promiseRejected(err) {
  2788. console.error("错误信息: ", err.message)
  2789. }
  2790. })
  2791. }
  2792. function statistic() {
  2793. var checks = document.getElementsByName("statistics1CheckBox");
  2794. statisticCheckBoxArray.splice(0, statisticCheckBoxArray.length);
  2795. for (var i = 0; i < checks.length; i++) {
  2796. if (checks[i].checked) {
  2797. statisticCheckBoxArray.push(checks[i].value)
  2798. }
  2799. }
  2800. if (statisticCheckBoxArray.length < 1) {
  2801. alert("请至少选择一个街道");
  2802. return
  2803. }
  2804. statisticResultList.splice(0, statisticResultList.length);
  2805. btClear_Click();
  2806. document.getElementById("statistics1").style.display = "none";
  2807. document.getElementById("statistics2").style.display = "";
  2808. recursive(0)
  2809. }
  2810. function recursive(value) {
  2811. if (value < statisticCheckBoxArray.length) {
  2812. var options = document.getElementById("statistics1LayerSelect").options;
  2813. queryPolygonByStatistic(statisticCheckBoxArray[value], options[options.selectedIndex].value, value)
  2814. }
  2815. }
  2816. function queryPolygonByStatistic(name, urlid, value) {
  2817. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom"],
  2818. function (QueryTask, Query, FeatureLayer, arrayUtils, dom) {
  2819. var url = dyLayer.url + "/" + GetLayerIdbyName("街道乡镇");
  2820. var qTask = new QueryTask({
  2821. url: url
  2822. });
  2823. var params = new Query({
  2824. returnGeometry: true,
  2825. outFields: ["*"]
  2826. });
  2827. params.where = "名称='" + name + "'";
  2828. qTask.execute(params).then(getResults).otherwise(promiseRejected);
  2829. function getResults(response) {
  2830. var peakResults = arrayUtils.map(response.features,
  2831. function (feature) {
  2832. return feature
  2833. });
  2834. queryPointByStatistic(peakResults[0].geometry, urlid, value)
  2835. }
  2836. function promiseRejected(err) {
  2837. console.error("错误信息: ", err.message)
  2838. }
  2839. })
  2840. }
  2841. function queryPointByStatistic(geometry, urlid, value) {
  2842. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom"],
  2843. function (QueryTask, Query, FeatureLayer, arrayUtils, dom) {
  2844. var url = dyLayer.url + "/" + urlid;
  2845. var qTask = new QueryTask({
  2846. url: url
  2847. });
  2848. var params = new Query({
  2849. geometry: geometry,
  2850. returnGeometry: true,
  2851. outFields: ["*"]
  2852. });
  2853. params.where = "1=1";
  2854. qTask.execute(params).then(getResults).otherwise(promiseRejected);
  2855. function getResults(response) {
  2856. var peakResults = arrayUtils.map(response.features,
  2857. function (feature) {
  2858. if (currentMapMode == "2D") {
  2859. var obj = eval("(" + symble[urlid] + ")");
  2860. var symbolJson = obj.drawingInfo.renderer.symbol;
  2861. if (symbolJson.type == "esriSFS") {
  2862. feature.symbol = {
  2863. type: "simple-fill",
  2864. style: changeStyle(symbolJson.style),
  2865. color: symbolJson.color,
  2866. outline: {
  2867. style: changeStyle(symbolJson.outline.style),
  2868. color: symbolJson.outline.color,
  2869. width: symbolJson.outline.width
  2870. }
  2871. }
  2872. } else if (symbolJson.type == "esriPMS") {
  2873. feature.symbol = {
  2874. type: "picture-marker",
  2875. url: "data:image/png;base64," + symbolJson.imageData,
  2876. width: symbolJson.width,
  2877. height: symbolJson.height
  2878. }
  2879. } else if (symbolJson.style == "esriSMSCircle") {
  2880. feature.symbol = {
  2881. type: "simple-marker",
  2882. style: "circle",
  2883. color: symbolJson.color,
  2884. size: symbolJson.size,
  2885. outline: {
  2886. color: symbolJson.outline.color,
  2887. width: symbolJson.outline.width
  2888. }
  2889. }
  2890. }
  2891. } else {
  2892. var verticalOffset = {
  2893. screenLength: 40,
  2894. maxWorldLength: 200,
  2895. minWorldLength: 35
  2896. };
  2897. var obj = eval("(" + symble[urlid] + ")");
  2898. var symbolJson = obj.drawingInfo.renderer.symbol;
  2899. if (symbolJson.type == "esriSFS") {
  2900. for (var i = 0; i < feature.geometry.rings[0].length; i++) {
  2901. feature.geometry.rings[0][i].push(20)
  2902. }
  2903. var polygon = {
  2904. type: "polygon",
  2905. rings: feature.geometry.rings
  2906. };
  2907. var polygonGraphic = new Graphic({
  2908. geometry: polygon
  2909. });
  2910. polygonGraphic.symbol = {
  2911. type: "polygon-3d",
  2912. symbolLayers: [{
  2913. type: "fill",
  2914. material: {
  2915. color: symbolJson.color
  2916. },
  2917. outline: {
  2918. color: symbolJson.outline.color,
  2919. size: symbolJson.outline.size
  2920. }
  2921. }]
  2922. }
  2923. } else if (symbolJson.type == "esriPMS") {
  2924. feature.symbol = {
  2925. type: "point-3d",
  2926. symbolLayers: [{
  2927. type: "icon",
  2928. resource: {
  2929. href: "data:image/png;base64," + symbolJson.imageData
  2930. },
  2931. size: 20,
  2932. outline: {
  2933. color: "white",
  2934. size: 2
  2935. }
  2936. }],
  2937. verticalOffset: verticalOffset,
  2938. callout: {
  2939. type: "line",
  2940. color: "white",
  2941. size: 2,
  2942. border: {
  2943. color: "#40C2B4"
  2944. }
  2945. }
  2946. }
  2947. } else if (symbolJson.style == "esriSMSCircle") {
  2948. feature.symbol = {
  2949. type: "point-3d",
  2950. symbolLayers: [{
  2951. type: "icon",
  2952. resource: {
  2953. primitive: "circle"
  2954. },
  2955. size: symbolJson.size * 2,
  2956. material: {
  2957. color: symbolJson.color
  2958. },
  2959. outline: {
  2960. color: symbolJson.outline.color,
  2961. size: symbolJson.outline.size
  2962. }
  2963. }],
  2964. verticalOffset: verticalOffset,
  2965. callout: {
  2966. type: "line",
  2967. color: "white",
  2968. size: 2,
  2969. border: {
  2970. color: "#40C2B4"
  2971. }
  2972. }
  2973. }
  2974. }
  2975. }
  2976. var popupTemplate = {
  2977. title: "详细信息",
  2978. content: attributesToHTMLStr(feature.attributes)
  2979. };
  2980. if (currentMapMode == "3D") {
  2981. if (symbolJson.type == "esriSFS") {
  2982. polygonGraphic.geometry.spatialReference = m_view.spatialReference;
  2983. polygonGraphic.popupTemplate = popupTemplate;
  2984. return polygonGraphic
  2985. }
  2986. }
  2987. feature.geometry.spatialReference = m_view.spatialReference;
  2988. feature.popupTemplate = popupTemplate;
  2989. return feature
  2990. });
  2991. statisticResultList.push({
  2992. "名称": statisticCheckBoxArray[statisticResultList.length],
  2993. "数量": peakResults.length,
  2994. "图形集": peakResults
  2995. });
  2996. GraphicsLayer_myLayer.addMany(peakResults);
  2997. if (statisticResultList.length == statisticCheckBoxArray.length) {
  2998. m_view.goTo(GraphicsLayer_myLayer.graphics);
  2999. dyCretateTableByArray("statistics2Table", statisticResultList, ["名称", "数量"], ["名称", "数量"], false, true);
  3000. creatPie(statisticResultList, "statistics2Div2");
  3001. createBar(statisticResultList, "statistics2Div3")
  3002. }
  3003. recursive(value + 1)
  3004. }
  3005. function promiseRejected(err) {
  3006. console.error("错误信息: ", err.message)
  3007. }
  3008. })
  3009. }
  3010. function openRoadQuery() {
  3011. document.getElementById("roadQuery").style.display = ""
  3012. }
  3013. function closeRoadQuery() {
  3014. document.getElementById("roadQuery").style.display = "none"
  3015. }
  3016. function searchRoadByName() {
  3017. var address = document.getElementById("addressName").value;
  3018. if (address == "") {
  3019. alert("请输入要检索的关键字!");
  3020. return
  3021. }
  3022. openRoadQuery();
  3023. searchRoadName = address;
  3024. searchRoadPage(1)
  3025. }
  3026. function showRoadPoint(x, y, name) {
  3027. require(["esri/Graphic"],
  3028. function (Graphic) {
  3029. var point = {
  3030. type: "point",
  3031. x: x,
  3032. y: y,
  3033. spatialReference: m_view.spatialReference
  3034. };
  3035. var markerSymbol;
  3036. if (currentMapMode == "2D") {
  3037. markerSymbol = {
  3038. type: "picture-marker",
  3039. url: "QPimage/top/layerPopup.png",
  3040. width: "20px",
  3041. height: "30px"
  3042. }
  3043. } else {
  3044. var verticalOffset = {
  3045. screenLength: 40,
  3046. maxWorldLength: 200,
  3047. minWorldLength: 35
  3048. };
  3049. markerSymbol = {
  3050. type: "point-3d",
  3051. symbolLayers: [{
  3052. type: "icon",
  3053. resource: {
  3054. href: "QPimage/top/layerPopup.png"
  3055. },
  3056. size: 20
  3057. }],
  3058. verticalOffset: verticalOffset,
  3059. callout: {
  3060. type: "line",
  3061. color: "white",
  3062. size: 2,
  3063. border: {
  3064. color: "#40C2B4"
  3065. }
  3066. }
  3067. }
  3068. }
  3069. var pointGraphic = new Graphic({
  3070. geometry: point,
  3071. symbol: markerSymbol
  3072. });
  3073. pointGraphic.attributes = {
  3074. roadname: name
  3075. };
  3076. GraphicsLayer_myLayer.add(pointGraphic)
  3077. })
  3078. }
  3079. function showRoad(x, y) {
  3080. require(["esri/geometry/Point"],
  3081. function (Point) {
  3082. var point = new Point({
  3083. x: x,
  3084. y: y,
  3085. spatialReference: m_view.spatialReference
  3086. });
  3087. m_view.goTo(point)
  3088. })
  3089. }
  3090. function doToolTip() {
  3091. m_view.on("pointer-move", eventHandler);
  3092. function eventHandler(event) {
  3093. m_view.hitTest(event).then(getGraphics)
  3094. }
  3095. function getGraphics(response) {
  3096. if (response.results.length) {
  3097. var graphic = response.results.filter(function (result) {
  3098. return result.graphic.layer === GraphicsLayer_myLayer
  3099. })[0].graphic;
  3100. var attributes = graphic.attributes;
  3101. var roadname = attributes.roadname;
  3102. if (roadname != null) {
  3103. document.getElementById("info").style.visibility = "visible";
  3104. document.getElementById("info").innerHTML = roadname
  3105. }
  3106. }
  3107. }
  3108. }
  3109. function createInfoDiv() {
  3110. var dom = document.createElement("div");
  3111. dom.setAttribute("id", "info");
  3112. dom.setAttribute("style", "background-color: black;opacity: 0.75;color: orange; font-size: 18pt; padding: 8px;visibility: hidden;");
  3113. document.body.appendChild(dom)
  3114. }
  3115. function showLoadingDiv(message) {
  3116. var loadingDiv = document.createElement("div");
  3117. loadingDiv.setAttribute("id", "divLoading");
  3118. loadingDiv.innerHTML = message;
  3119. var iWidth = 200;
  3120. var iHeight = 50;
  3121. var iTop = (window.screen.height - 30 - iHeight) / 2;
  3122. var iLeft = (window.screen.width - 10 - iWidth) / 2;
  3123. loadingDiv.setAttribute("style", "position: absolute;height:" + iHeight + "px;width:" + iWidth + "px;top:" + iTop + "px;left:" + iLeft + "px;");
  3124. document.body.appendChild(loadingDiv)
  3125. }
  3126. function removeLoadingDiv() {
  3127. var loadingDiv = document.getElementById("divLoading");
  3128. if (loadingDiv) {
  3129. document.body.removeChild(loadingDiv)
  3130. }
  3131. }
  3132. function postToParentPageMethed(methedName, data, backFun) {//传数据给父窗口
  3133. window.parent.postMessage(JSON.stringify({method: methedName, data: data, backfun: backFun}), '*');
  3134. }
  3135. function OpenMapImageLayerByName(layerName, layerVisible, whereStr) {
  3136. if (whereStr == null) {
  3137. whereStr = "1=1"
  3138. }
  3139. if (whereStr == "") {
  3140. whereStr = "1=1"
  3141. }
  3142. if (layerName == "非法行医") {
  3143. var layer = getLayerByLayerId("动态数据");
  3144. var layerId = GetLayerIdbyName("存量点");
  3145. var symbol1 = {
  3146. type: "picture-marker",
  3147. url: "http://10.101.35.46/zhwj/assets/image/ffxyPoint.png",
  3148. width: "20px",
  3149. height: "20px"
  3150. }
  3151. var renderer1 = {
  3152. type: "simple",
  3153. symbol: symbol1
  3154. };
  3155. layer.findSublayerById(layerId).renderer = renderer1
  3156. layer.findSublayerById(layerId).definitionExpression = whereStr;
  3157. layer.findSublayerById(layerId).visible = layerVisible;
  3158. } else if (layerName == "六月内存量零") {
  3159. queryNoFFXYPointArea(6, layerVisible, whereStr)
  3160. } else if (layerName == "十二月内存量零") {
  3161. queryNoFFXYPointArea(12, layerVisible, whereStr)
  3162. } else if (layerName == "街道乡镇") {
  3163. var layer = getLayerByLayerId("动态数据");
  3164. var id = getSubLayerIdbyName(layer, "街道乡镇");
  3165. if (layer.findSublayerById(id).sublayers) {
  3166. var subLayer = layer.findSublayerById(id).sublayers.items;
  3167. for (var i = 0; i < subLayer.length; i++) {
  3168. layer.findSublayerById(subLayer[i].id).definitionExpression = whereStr;
  3169. }
  3170. } else {
  3171. layer.findSublayerById(id).definitionExpression = whereStr;
  3172. }
  3173. layer.findSublayerById(id).visible = layerVisible;
  3174. layer.findSublayerById(id).renderer ={
  3175. type: "simple", // autocasts as new PointSymbol3D()
  3176. symbol:{
  3177. type: "simple-fill",
  3178. color: [0,0,0,0],
  3179. style: "solid",
  3180. outline: {
  3181. color: [168, 168, 0, 255],
  3182. width: 1
  3183. }
  3184. }
  3185. }
  3186. } else {
  3187. var layer = getLayerByLayerId("density_1");
  3188. var id = getSubLayerIdbyName(layer, layerName);
  3189. if (layer.findSublayerById(id).sublayers) {
  3190. var subLayer = layer.findSublayerById(id).sublayers.items;
  3191. for (var i = 0; i < subLayer.length; i++) {
  3192. layer.findSublayerById(subLayer[i].id).definitionExpression = whereStr;
  3193. }
  3194. } else {
  3195. layer.findSublayerById(id).definitionExpression = whereStr;
  3196. }
  3197. layer.findSublayerById(id).visible = layerVisible;
  3198. }
  3199. }
  3200. function addZero(num) {
  3201. if (num < 10) {
  3202. return "0" + num;
  3203. } else {
  3204. return num;
  3205. }
  3206. }
  3207. function createWZXYFeature() {
  3208. require(["esri/tasks/QueryTask", "esri/tasks/support/StatisticDefinition", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom", "esri/Graphic",
  3209. "esri/geometry/Point"],
  3210. function (QueryTask, StatisticDefinition, Query, FeatureLayer, arrayUtils, dom, Graphic, Point) {
  3211. var layer2 = getLayerByLayerId("density_1");
  3212. var id = getSubLayerIdbyName(layer2, "街道乡镇");
  3213. var qTask = new QueryTask({
  3214. url:layer2.url+"/"+id
  3215. });
  3216. var query = new Query();
  3217. query.returnGeometry = true;
  3218. query.outFields = ["*"];
  3219. query.where = "1=1";
  3220. qTask.execute(query).then(getResults).catch(promiseRejected);
  3221. function getResults(response) {
  3222. const layer = new FeatureLayer({
  3223. id:"WZXYFeature",
  3224. source: response.features,
  3225. fields: [{
  3226. name: "ObjectID",
  3227. alias: "ObjectID",
  3228. type: "oid"
  3229. }, {
  3230. name: "街道名称",
  3231. alias: "街道名称",
  3232. type: "string"
  3233. }],
  3234. outFields : ["ObjectID","街道名称"],
  3235. visible:false,
  3236. objectIdField: "ObjectID",
  3237. geometryType: "polygon"
  3238. });
  3239. layer.renderer={
  3240. type: "simple", // autocasts as new PointSymbol3D()
  3241. symbol:{
  3242. type: "simple-fill", // autocasts as new SimpleFillSymbol()
  3243. color: [168, 168, 0, 0.3],
  3244. style: "solid",
  3245. outline: { // autocasts as new SimpleLineSymbol()
  3246. color: [168, 168, 0, 255],
  3247. width: 2
  3248. }
  3249. }
  3250. }
  3251. m_map.add(layer)
  3252. };
  3253. function promiseRejected(e) {
  3254. console.log(e)
  3255. }
  3256. })
  3257. }
  3258. function queryNoFFXYPointArea(month, layerVisible, whereStr) {// 零无证行医区域
  3259. var layer2 = getLayerByLayerId("density_1");
  3260. if (layerVisible == false) {
  3261. var WZXYFeature = getLayerByLayerId("WZXYFeature");
  3262. WZXYFeature.definitionExpression = "1=1";
  3263. WZXYFeature.visible = false;
  3264. return
  3265. }
  3266. var dt = new Date();
  3267. dt.setMonth(dt.getMonth() - month);
  3268. var where = " 创建日期1 >'" + dt.getFullYear() + "/" + addZero(dt.getMonth() + 1) + "/" + addZero(dt.getDate()) + "'";
  3269. var layerId = GetLayerIdbyName("存量点");
  3270. if (layerId == -1)
  3271. return;
  3272. require(["esri/tasks/QueryTask", "esri/tasks/support/StatisticDefinition", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom", "esri/Graphic",
  3273. "esri/geometry/Point"],
  3274. function (QueryTask, StatisticDefinition, Query, FeatureLayer, arrayUtils, dom, Graphic, Point) {
  3275. var layer = getLayerByLayerId("动态数据");
  3276. var urlI = layer.url + "/" + layerId;
  3277. var qTask = new QueryTask({
  3278. url: urlI
  3279. });
  3280. var query = new Query();
  3281. var levelCount = new StatisticDefinition({
  3282. statisticType: "count",
  3283. onStatisticField: "ID",
  3284. outStatisticFieldName: "level_count"
  3285. });
  3286. query.outFields = ["*"];
  3287. query.returnGeometry = false;
  3288. query.groupByFieldsForStatistics = ["街道"];
  3289. query.outStatistics = [levelCount];
  3290. query.where = where;
  3291. qTask.execute(query).then(getResults).catch(promiseRejected);
  3292. function getResults(response) {
  3293. var graphiics = response.features;
  3294. var areaWhere = "街道名称 not in ('' ";
  3295. for (var i = 0; i < graphiics.length; i++) {
  3296. if (i % 10 == 0 && i != 0) {
  3297. areaWhere += " ) and 街道名称 not in (''"
  3298. } else {
  3299. areaWhere += ",'" + graphiics[i].attributes.街道 + "'";
  3300. }
  3301. }
  3302. areaWhere += ")";
  3303. if (whereStr) {
  3304. areaWhere += " and " + whereStr;
  3305. }
  3306. var WZXYFeature = getLayerByLayerId("WZXYFeature");
  3307. WZXYFeature.definitionExpression = areaWhere;
  3308. WZXYFeature.visible = layerVisible;
  3309. // layer2.findSublayerById(id2).definitionExpression = areaWhere;
  3310. // // layer2.findSublayerById(id3).definitionExpression = areaWhere;
  3311. // layer2.findSublayerById(id4).definitionExpression = areaWhere;
  3312. // // layer2.findSublayerById(id5).definitionExpression = areaWhere;
  3313. // layer2.findSublayerById(id2).visible = layerVisible;
  3314. // layer2.findSublayerById(id4).renderer={
  3315. // type: "simple", // autocasts as new PointSymbol3D()
  3316. // symbol:{
  3317. // type: "simple-fill", // autocasts as new SimpleFillSymbol()
  3318. // color: [168, 168, 0, 0.3],
  3319. // style: "solid",
  3320. // outline: { // autocasts as new SimpleLineSymbol()
  3321. // color: [168, 168, 0, 255],
  3322. // width: 2
  3323. // }
  3324. // }
  3325. // }
  3326. }
  3327. function promiseRejected(err) {
  3328. console.error("错误信息: ", err.message);
  3329. }
  3330. });
  3331. }
  3332. function queryNoFFXYPointJCZ(month, layerVisible, radius) {// 零无证行医区域
  3333. var layerId = GetLayerIdbyName("固定监测站");
  3334. if (layerId == -1)
  3335. return;
  3336. require(["esri/tasks/QueryTask", "esri/tasks/support/StatisticDefinition", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom", "esri/Graphic",
  3337. "esri/geometry/Point"],
  3338. function (QueryTask, StatisticDefinition, Query, FeatureLayer, arrayUtils, dom, Graphic, Point) {
  3339. var layer = getLayerByLayerId("动态数据");
  3340. var urlI = layer.url + "/" + layerId;
  3341. var qTask = new QueryTask({
  3342. url: urlI
  3343. });
  3344. var query = new Query();
  3345. query.returnGeometry = true;
  3346. query.outFields=["*"];
  3347. query.where = "1=1";
  3348. qTask.execute(query).then(getResults).catch(promiseRejected);
  3349. function getResults(response) {
  3350. var graphiics = response.features;
  3351. for (var i = 0; i < graphiics.length; i++) {
  3352. var x = graphiics[i].geometry.x;
  3353. var y = graphiics[i].geometry.y;
  3354. xmlAddPointJCZ(x,y, null, null, null, null, null, null, null, null,radius)
  3355. }
  3356. }
  3357. function promiseRejected(err) {
  3358. console.error("错误信息: ", err.message);
  3359. }
  3360. });
  3361. }
  3362. function doCorrugatedPointByOid(idLlist) {
  3363. var where = "ORGANIZATION_ID1 in ("
  3364. for (var i = 0; i < idLlist.length; i++) {
  3365. where += "'" + idLlist[i] + "', "
  3366. }
  3367. where += "'0')";
  3368. var layerId = GetLayerIdbyName("医疗机构");
  3369. m_map.remove(corrugatedPointlayer);
  3370. if (layerId == -1)
  3371. return;
  3372. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom", "esri/Graphic",
  3373. "esri/geometry/Point"],
  3374. function (QueryTask, Query, FeatureLayer, arrayUtils, dom, Graphic, Point) {
  3375. var layer = getLayerByLayerId("动态数据");
  3376. var urlI = layer.url + "/" + layerId;
  3377. var qTask = new QueryTask({
  3378. url: urlI
  3379. });
  3380. var params = new Query({
  3381. returnGeometry: true,
  3382. outFields: ["*"]
  3383. });
  3384. params.where = where;
  3385. qTask.execute(params).then(getResults).catch(promiseRejected);
  3386. function getResults(response) {
  3387. var graphicArray = []
  3388. if (response.features.length == 0) {
  3389. return;
  3390. }
  3391. $.each(response.features, function (index, feature) {
  3392. var point = {
  3393. type: "point", // autocasts as new Point()
  3394. x: parseFloat(x),
  3395. y: parseFloat(y),
  3396. spatialReference: m_view.spatialReference
  3397. };
  3398. var pointGraphic = new Graphic({
  3399. geometry: feature.geometry,
  3400. attributes: feature.attributes
  3401. });
  3402. graphicArray.push(pointGraphic);
  3403. });
  3404. createCorrugatedPoint(null, graphicArray, m_map);
  3405. }
  3406. function promiseRejected(err) {
  3407. console.error("错误信息: ", err.message);
  3408. }
  3409. });
  3410. }
  3411. function doClearCorrugatedPoint() {
  3412. m_map.remove(corrugatedPointlayer);
  3413. }
  3414. function goToGraphic(type,list) {
  3415. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom", "esri/Graphic",
  3416. "esri/geometry/Point"],
  3417. function (QueryTask, Query, FeatureLayer, arrayUtils, dom, Graphic, Point) {
  3418. if(type=="点"){
  3419. var pointList=[];
  3420. for(var i=0;i<list.length;i++){
  3421. var point = {
  3422. type: "point",
  3423. x: list[i][0],
  3424. y:list[i][1],
  3425. spatialReference: m_view.spatialReference
  3426. };
  3427. var markerSymbol = {
  3428. type: "simple-marker", // autocasts as new SimpleMarkerSymbol()
  3429. color: [226, 119, 40]
  3430. };
  3431. // Create a graphic and add the geometry and symbol to it
  3432. const pointGraphic = new Graphic({
  3433. geometry: point,
  3434. symbol: markerSymbol
  3435. });
  3436. pointList.push(pointGraphic)
  3437. }
  3438. m_view.goTo(pointList)
  3439. }else if(type=="街道乡镇"){
  3440. var layer = getLayerByLayerId("动态数据");
  3441. var layerId = getSubLayerIdbyName(layer, "街道乡镇");
  3442. var urlI = layer.url + "/" + layerId;
  3443. var qTask = new QueryTask({
  3444. url: urlI
  3445. });
  3446. var params = new Query({
  3447. returnGeometry: true,
  3448. outFields: ["*"]
  3449. });
  3450. params.where = list;
  3451. qTask.execute(params).then(getResults) ;
  3452. function getResults(response) {
  3453. m_view.goTo(response.features)
  3454. }
  3455. }else{
  3456. var layer = getLayerByLayerId("density_1");
  3457. var layerId = getSubLayerIdbyName(layer, type);
  3458. var urlI = layer.url + "/" + layerId;
  3459. var qTask = new QueryTask({
  3460. url: urlI
  3461. });
  3462. var params = new Query({
  3463. returnGeometry: true,
  3464. outFields: ["*"]
  3465. });
  3466. params.where = list;
  3467. qTask.execute(params).then(getResults) ;
  3468. function getResults(response) {
  3469. m_view.goTo(response.features)
  3470. }
  3471. }
  3472. })
  3473. }
  3474. function doXyToStreetId(x, y) {
  3475. var layer = getLayerByLayerId("density_1");
  3476. var layerId = getSubLayerIdbyName(layer, "街道乡镇");
  3477. if (layerId == -1) {
  3478. return;
  3479. }
  3480. require(["esri/tasks/QueryTask", "esri/tasks/support/Query", "esri/layers/FeatureLayer", "dojo/_base/array", "dojo/dom", "esri/Graphic",
  3481. "esri/geometry/Point"],
  3482. function (QueryTask, Query, FeatureLayer, arrayUtils, dom, Graphic, Point) {
  3483. var urlI = layer.url + "/" + layerId;
  3484. var qTask = new QueryTask({
  3485. url: urlI
  3486. });
  3487. var params = new Query({
  3488. returnGeometry: true,
  3489. outFields: ["*"]
  3490. });
  3491. var point = {
  3492. type: "point",
  3493. x: x,
  3494. y: y,
  3495. spatialReference: m_view.spatialReference
  3496. };
  3497. params.geometry = point;
  3498. qTask.execute(params).then(getResults).catch(promiseRejected);
  3499. function getResults(response) {
  3500. postToParentPageMethed("doXyToStreetIdReturn", [response.features[0].attributes.街道代码]);
  3501. }
  3502. function promiseRejected(err) {
  3503. console.error("错误信息: ", err.message);
  3504. }
  3505. });
  3506. }
  3507. function queryResetNumByType(whereStr) {
  3508. var url = xmlUtil.getNodeValue(xmlDoc.getElementsByTagName("WebServiceURL")[0]);
  3509. var sql = "select t.water_source_name,t.water_work_name,t.area_name," +
  3510. "t.water_source_gps_x_cd x1,t.water_source_gps_y_cd y1," +
  3511. "t.water_work_gps_x_cd x2,t.water_work_gps_y_cd y2" +
  3512. ",t.area_gps_x_cd x3,t.area_gps_y_cd y3 from dwd_water_source_tracing t where " + whereStr;
  3513. WsCommonClass("QueryDataBaseJson", ["sql"], [sql], sqlReturn, "queryResetNumByType", url);
  3514. }
  3515. function ShowBuildlayer(where){
  3516. var layer=getLayerByLayerId("建筑物");
  3517. layer.visible=where;
  3518. }
  3519. function ShowBuildlayerSX(where){
  3520. var layer=getLayerByLayerId("水箱");
  3521. layer.visible=where;
  3522. }
  3523. function ResettingMap() {
  3524. require(["esri/geometry/Point"],
  3525. function (Point) {
  3526. var centerPoint = new Point({
  3527. //x: 43184,
  3528. //y: -37270,
  3529. x:0,
  3530. y:0,
  3531. z: 258000,
  3532. spatialReference: m_view.spatialReference
  3533. });
  3534. setCameraBypoint(0, centerPoint, 0, 0, currentScale);
  3535. });
  3536. }
  3537. function consoleXYZ() {
  3538. console.log(m_view.camera.position)
  3539. }
  3540. function queryWaterTank(id) {
  3541. var url = xmlUtil.getNodeValue(xmlDoc.getElementsByTagName("WebServiceURL")[0]);
  3542. var sql="select t.near_x,t.near_y,t.二次供水设,t.关联二次供 from sxd t where t.objectid="+id;
  3543. WsCommonClass("QueryDataBaseJson", ["sql"], [sql], sqlReturnWater, "queryWaterTank", url);
  3544. }
  3545. function sqlReturnWater(evt, keyValue) {
  3546. var allCount;
  3547. var pageIndex;
  3548. var jsonArray;
  3549. if (evt[0] != null) {
  3550. allCount = JSON.parse(evt[0].textContent)[0].AllCount;
  3551. pageIndex = JSON.parse(evt[0].textContent)[0].pageIndex;
  3552. jsonArray = JSON.parse(evt[0].textContent)[0].data;
  3553. } else {
  3554. jsonArray = []
  3555. }
  3556. switch (keyValue) {
  3557. case "queryWaterTank":{
  3558. var arr={"sbh":jsonArray[0].二次供水设,"x":jsonArray[0].near_x,"y":jsonArray[0].near_y,"xq":jsonArray[0].关联二次供};
  3559. postToParentPageMethed("clickWaterTankReturn", [arr]);
  3560. break;
  3561. }
  3562. }
  3563. }
  3564. function clusterByJson(list) {
  3565. require(["esri/layers/FeatureLayer", "esri/Graphic","esri/widgets/Legend"], function(FeatureLayer, Graphic,Legend) {
  3566. m_map.remove(m_map.findLayerById("clusterByJsonLayer"));
  3567. var clusterConfig = {
  3568. type: "cluster",
  3569. clusterRadius: "50px",//多少范围聚合
  3570. labelsVisible: true,
  3571. labelingInfo: [
  3572. {
  3573. symbol: {
  3574. type: "text",
  3575. color:"yellow",//聚合字的颜色
  3576. font: {
  3577. size: "15px"
  3578. }
  3579. },
  3580. labelPlacement: "center-center",
  3581. labelExpressionInfo: {
  3582. expression: "Text($feature.cluster_count, '#,### ')"
  3583. },
  3584. where: '1=1'
  3585. }
  3586. ]
  3587. };
  3588. var graphics=[];
  3589. for(var i=0;i<list.length;i++){
  3590. var point = { // 点坐标
  3591. type: "point",
  3592. x: parseFloat(list[i].x),
  3593. y: parseFloat(list[i].y),
  3594. spatialReference: m_view.spatialReference
  3595. };
  3596. var Graphics2 = new Graphic({
  3597. geometry: point,
  3598. // symbol: pointSymbol
  3599. });
  3600. graphics.push(Graphics2);
  3601. }
  3602. var clusterLayer = new FeatureLayer({
  3603. id: "clusterByJsonLayer",
  3604. fields: [{
  3605. name: "code",
  3606. alias: "code",
  3607. type: "double"
  3608. } ],
  3609. visible: true,
  3610. objectIdField: "code", // inferred from fields array if not specified
  3611. geometryType: "point",
  3612. spatialReference: m_view.spatialReference,
  3613. source: graphics,
  3614. featureReduction: clusterConfig,
  3615. labelsVisible: true,
  3616. renderer: {
  3617. type: "simple",
  3618. symbol:{
  3619. type: "simple-marker",
  3620. color: [123, 0, 0, 0.4],//聚合圈的颜色
  3621. size: "10px"
  3622. }
  3623. }
  3624. });
  3625. m_map.add(clusterLayer);
  3626. });
  3627. }