MainMap.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. var layer_vector, layer_image, layer_POI, map,layer_SC;
  2. var layer_RouteLine, layer_RoutePoi;
  3. var graphicLayer_RouteLine;
  4. var redColor, blueColor;
  5. var geoService;
  6. var layerUrl_cd_vector = "http://125.70.9.221:8020/cdmap/rest/services/BASEMAP/Vector/MapServer";
  7. var layerUrl_cd_raster = "http://125.70.9.221:8020/cdmap/rest/services/BASEMAP/Raster/MapServer";
  8. var layerUrl_POI = "http://123.146.170.78:6080/arcgis/rest/services/SCPOI2/MapServer/1";
  9. var layerUrl_SC = "http://123.146.170.78:6080/arcgis/rest/services/SCPOI2/MapServer/";
  10. dojoConfig = {
  11. parseOnLoad: true,
  12. packages: [{
  13. name: 'tdlib',
  14. location: this.location.pathname.replace(/\/[^/]+$/, "") + "/js/tdlib"
  15. }]
  16. };
  17. require(["esri/map", "tdlib/TDTLayer", "tdlib/TDTRasterLayer", "tdlib/TDTAnnoLayer", "esri/layers/FeatureLayer","esri/InfoTemplate",
  18. "esri/geometry/Point", "esri/layers/GraphicsLayer", "esri/Color","esri/layers/ArcGISDynamicMapServiceLayer", "dojo/domReady!"],
  19. function (Map, TDTLayer, TDTRasterLayer, TDTAnnoLayer, FeatureLayer, InfoTemplate, Point, GraphicsLayer, Color, ArcGISDynamicMapServiceLayer) {
  20. var pt = new Point(104.06464933797728, 30.66198193058378);
  21. map = new Map("divMap", { logo: false, center: pt, zoom: 7 });
  22. layer_vector = new TDTLayer();
  23. layer_vector.id = "tianDiTu_vec";
  24. layer_vector.visible = false;
  25. map.addLayer(layer_vector);
  26. layer_image = new TDTRasterLayer();
  27. layer_image.id = "tianDiTu_img";
  28. layer_image.visible = false;
  29. map.addLayer(layer_image);
  30. layer_SC = new ArcGISDynamicMapServiceLayer(layerUrl_SC, {
  31. useMapImage: true,
  32. });
  33. layer_SC.setVisibleLayers([]);
  34. map.addLayer(layer_SC);
  35. var template_POI = {
  36. title: "${NAME}",
  37. content: "<table><tr>" +
  38. "<td><ul><li>名称:${NAME}</li><li>类型:${CTYPE}</li><li>区域:${CITY}-${DISTRICT}</li><li>电话:${TEL}</li><li>地址:${ADDRESS}</li></ul></td>" +
  39. "<td><img src='${PIC}' style='width:100%;height:100%' /></td></t></table>"
  40. };
  41. var infoTemplate_POI = new InfoTemplate(template_POI);
  42. layer_POI = new FeatureLayer(layerUrl_POI,{
  43. definitionExpression: "CTYPE='1'",
  44. infoTemplate: infoTemplate_POI,
  45. outFields: ["*"]
  46. });
  47. map.addLayer(layer_POI);
  48. graphicLayer_RouteLine = new GraphicsLayer({ id: "graphicLayer_RouteLine" });
  49. map.addLayer(graphicLayer_RouteLine);
  50. map.on('click', function (event) {
  51. if (isSetBufferCenter) {
  52. $("#txtBufferX").val(event.mapPoint.x);
  53. $("#txtBufferY").val(event.mapPoint.y);
  54. showEventPoint(event.mapPoint.x, event.mapPoint.y);
  55. isSetBufferCenter = false;
  56. }
  57. //var txt = $("#txtCoord").val()+ '['+ event.mapPoint.x + ',' + event.mapPoint.y + ']'
  58. var txt = event.mapPoint.x + ',' + event.mapPoint.y;
  59. $("#txtCoord").val(txt);
  60. });
  61. showLayer('vector');
  62. //初始化颜色
  63. redColor = new Color([255, 0, 0]);
  64. blueColor = new Color([0, 0, 255]);
  65. }
  66. );
  67. function showLayer(layerType) {
  68. layer_image.setVisibility(false);
  69. layer_vector.setVisibility(false);
  70. switch (layerType) {
  71. case 'vector':
  72. layer_vector.setVisibility(true);
  73. break;
  74. case 'image':
  75. layer_image.setVisibility(true);
  76. break;
  77. }
  78. }
  79. function addressQuery() {
  80. var queryValue = $("#txtQuery").val();
  81. var queryUrl = "http://www.scgis.net.cn/imap/imapserver/defaultrest/services/Newscnamesearch//Search?keyname=" + queryValue + "&typeCode=&DiQuKey=&QuXianKey=&isOnlyName=false&token=i44984NioeS2YQXAEi-NWImtfxFPNSx67E928s7whNAS9nH0uwTuO_YsKaxDdaxtdXi83flyMrcC9oG5S32Duw..&SearchEnvelope=&StartIndex=0&StopIndex=1000&ST=92916&callback=dojo.io.script.jsonp_dojoIoScript4._jsonpCallback";
  82. $.ajax({
  83. url: queryUrl,
  84. success: function (data) {
  85. data = data.replace('dojo.io.script.jsonp_dojoIoScript4._jsonpCallback(', '');
  86. data = data.replace(');', '');
  87. var result = eval('(' + data + ')');
  88. alert(result.message.features.length);
  89. var txt = "";
  90. map.graphics.clear();
  91. //for (i = 0; i < result.message.features.length; i++) {
  92. // txt += result.message.features[i].attributes[3] + ',';
  93. // var feature = result.message.features[i];
  94. // var attr = { name: feature.attributes[3], type: feature.attributes[4], address: feature.attributes[8], pic: feature.attributes[10] };
  95. // addPoint(feature.attributes[1], feature.attributes[2], view.spatialReference, attr);
  96. //}
  97. txt = JSON.stringify(result.message.columns);
  98. txt = txt + JSON.stringify(result.message.features);
  99. $("#txtCoord").val(txt);
  100. }
  101. })
  102. }
  103. //添加点位
  104. function addPointGraphic(x, y, pic) {
  105. require(["esri/symbols/PictureMarkerSymbol", "esri/symbols/TextSymbol", "esri/geometry/Point", "esri/graphic"], function (PictureMarkerSymbol, TextSymbol, Point, Graphic) {
  106. var pt = new Point(x,y,map.spatialReference );
  107. var symbol = new PictureMarkerSymbol(pic,32,32);
  108. var ptGraphic = new Graphic(pt, symbol );
  109. map.graphics.add(ptGraphic);
  110. });
  111. }
  112. //
  113. //添加显示点
  114. function addPoint(x, y, spatialReference, attri) {
  115. require(["esri/symbols/PictureMarkerSymbol", "esri/symbols/TextSymbol", "esri/geometry/Point", "esri/graphic", "esri/InfoTemplate"], function (PictureMarkerSymbol, TextSymbol, Point, Graphic, InfoTemplate) {
  116. var pt = new Point({
  117. x: x,
  118. y: y,
  119. spatialReference: spatialReference
  120. });
  121. var symbol = new PictureMarkerSymbol( "images/mapIcon/qiangji32.png",32,32);
  122. var infoTemplate = new InfoTemplate("${NAME}","名称:${NAME}<br>类型:${TYPE}<br>地址:${ADDRESS}");
  123. var polylineGraphic = new Graphic(pt,symbol, attri,infoTemplate);
  124. map.graphics.add(polylineGraphic);
  125. var textSymbol = new TextSymbol({
  126. color: "white",
  127. backgroundColor: "green",
  128. haloColor: "black",
  129. haloSize: "1px",
  130. text: attri.name,
  131. xoffset: 3,
  132. yoffset: 3,
  133. font: {
  134. size: 12,
  135. family: "sans-serif",
  136. weight: "bolder"
  137. }
  138. });
  139. var txtGraphic = new Graphic( pt, textSymbol );
  140. map.graphics.add(txtGraphic);
  141. });
  142. }
  143. //添加显示线
  144. function addLine(pts, spatialReference,color) {
  145. require(["esri/geometry/Polyline", "esri/symbols/SimpleLineSymbol", "esri/Color", "esri/graphic"], function (Polyline, SimpleLineSymbol, Color,Graphic) {
  146. var paths = [pts];
  147. var line = new Polyline({
  148. paths: paths,
  149. spatialReference: spatialReference
  150. });
  151. var symbol = new SimpleLineSymbol(
  152.     SimpleLineSymbol.STYLE_SOLID,
  153.     color,
  154.     3
  155.   );
  156. var lineGraphic = new Graphic(line, symbol);
  157. graphicLayer_RouteLine.add(lineGraphic);
  158. map.setExtent(line.getExtent().expand(3));
  159. });
  160. }
  161. //专题图显示
  162. //仓库-1,加油站-2,派出所-3,危化品企业-4,学校-5,医疗卫生-6,应急避难场所-7
  163. $("#layerList li input").change(function (evt) {
  164. var where = "";
  165. var layerCheckes = $("#layerList li input");
  166. for (i = 0; i < layerCheckes.length; i++) {
  167. if (layerCheckes[i].checked) {
  168. where += layerCheckes[i].id.replace('zt_', '') + ",";
  169. }
  170. }
  171. if (where == "")
  172. where = "CTYPEID=-1";
  173. else
  174. where = "CTYPEID in (" + where.substring(0, where.length - 1) + ")";
  175. layer_POI.setDefinitionExpression(where);
  176. });
  177. //轨迹回放
  178. var timer_Route;
  179. var iPoint_Route;
  180. //实际行走险路
  181. var points_Route = [[104.12151233673112, 30.668625259399512], [104.11966697692887, 30.667809867858985], [104.11842243194596, 30.667251968383887], [104.1170062255861, 30.666822814941504], [104.11606208801285, 30.66639366149912], [104.1147746276857, 30.666050338745215], [104.11378757476822, 30.665792846679786], [104.11211387634293, 30.66519203186045], [104.11116973876969, 30.66493453979502], [104.11172763824479, 30.66347541809092], [104.11211387634293, 30.6624454498292], [104.11228553771988, 30.661329650879004], [104.11228553771988, 30.659870529174903], [104.11219970703141, 30.65866889953623], [104.11215679168721, 30.65656604766857], [104.11215679168721, 30.655192756652944], [104.11215679168721, 30.654162788391226], [104.11189929962178, 30.653347396850698], [104.11138431549092, 30.652188682556265], [104.11052600860616, 30.65055789947521], [104.10971061706567, 30.649141693115368], [104.10885231018091, 30.64759674072279], [104.10765068054224, 30.645708465576305], [104.10662071228052, 30.64459266662611], [104.10524742126489, 30.64313354492201], [104.10456077575708, 30.641416931152477], [104.10370246887231, 30.639700317382946], [104.10258666992212, 30.63832702636732], [104.1019000244143, 30.63661041259779], [104.10078422546411, 30.635237121582165], [104.1000975799563, 30.633949661255016], [104.09923927307153, 30.632490539550915], [104.09786598205591, 30.63085975646986], [104.09709350585962, 30.62940063476576], [104.09520523071315, 30.626654052734516], [104.09383193969752, 30.62528076171889], [104.09314529418971, 30.624250793457172], [104.09211532592799, 30.623907470703266], [104.09039871215846, 30.62356414794936], [104.08816711425807, 30.623392486572406], [104.08490554809596, 30.623220825195453], [104.08198730468776, 30.622877502441547], [104.08112899780299, 30.622877502441547], [104.08061401367213, 30.621160888672016], [104.08009902954127, 30.619100952148578], [104.07975570678737, 30.61704101562514], [104.07924072265651, 30.614723587036273], [104.07829658508327, 30.611891174316547], [104.07821075439479, 30.610689544677875], [104.0779532623294, 30.609402084350727], [104.07812492370635, 30.608200454712055], [104.07812492370635, 30.606998825073383], [104.07778160095245, 30.60528221130385], [104.07718078613311, 30.60356559753432], [104.07743827819854, 30.602707290649555], [104.0779532623294, 30.60184898376479], [104.07846824646026, 30.60081901550307], [104.07863990783721, 30.60030403137221], [104.07881156921417, 30.599445724487445], [104.07881156921417, 30.598415756225727], [104.07863990783721, 30.597729110717914], [104.0779532623294, 30.5970424652101]];
  182. //规定运输线路
  183. var points_Route_Must = [[104.1214522489628, 30.668844129226763], [104.12299720135537, 30.669530774734575], [104.12454215374795, 30.670217420242388], [104.12625876751748, 30.671075727127153], [104.1284045347294, 30.672105695388872], [104.13106528607217, 30.673307325027544], [104.13312522259561, 30.674251462600786], [104.13381186810342, 30.674852277420122], [104.13484183636514, 30.675023938797075], [104.13655845013467, 30.673993970535356], [104.13776007977334, 30.67313566365059], [104.13930503216592, 30.672277356765825], [104.14102164593545, 30.671075727127153], [104.14308158245889, 30.670217420242388], [104.1452273496708, 30.66987409748848], [104.14754477825967, 30.670045758865434], [104.14969054547159, 30.67038908161934], [104.15179339733926, 30.670732404373236], [104.15320960369912, 30.670818235061713], [104.15522662487832, 30.67116155781562], [104.15702906933633, 30.67141904988105], [104.1576727994999, 30.67141904988105], [104.15883151379434, 30.671247388504096], [104.15977565136758, 30.670732404373236], [104.16037646618692, 30.66991701283271], [104.16059104290811, 30.668715383194037], [104.16054812756387, 30.667513753555365], [104.16020480480996, 30.665840055130072], [104.15788737622108, 30.660518552444522], [104.15582743969765, 30.655712033889834], [104.15514079418983, 30.650218869827334], [104.15376750317421, 30.648158933303897], [104.15239421215858, 30.644039060257022], [104.15102092114296, 30.64060583271796], [104.14964763012733, 30.637515927932803], [104.14690104809608, 30.633739377639834], [104.14621440258827, 30.630306150100772], [104.14346782055702, 30.62687292256171], [104.1469638285795, 30.63422600206069], [104.14559053756388, 30.631136097275533], [104.14490389205606, 30.628389515244283], [104.14353060104044, 30.625642933213033], [104.14215731002481, 30.62220970567397], [104.14215731002481, 30.61946312364272], [104.13838075973185, 30.616373218857564], [104.13700746871622, 30.612596668564596], [104.1359775004545, 30.610536732041158], [104.13391756393106, 30.608133472763814], [104.13151430465372, 30.60573021348647], [104.12842439986856, 30.605043567978658], [104.12430452682169, 30.60298363145522], [104.12155794479044, 30.601610340439596], [104.11881136275919, 30.60126701768569], [104.11606478072794, 30.599550403916158], [104.11091493941935, 30.599893726670064], [104.10782503463419, 30.599550403916158], [104.10507845260294, 30.598863758408346], [104.10164522506388, 30.59852043565444], [104.09855532027872, 30.59852043565444], [104.09546541549356, 30.59852043565444], [104.09271883346231, 30.59749046739272], [104.09065889693888, 30.59749046739272], [104.08859896041544, 30.59852043565444], [104.08585237838419, 30.59852043565444], [104.08310579635294, 30.599550403916158], [104.08035921432169, 30.599893726670064], [104.07932924605996, 30.600022472702776], [104.07872843124062, 30.60019413407973], [104.0788142619291, 30.599722065293108], [104.07868551589638, 30.598992504441057], [104.07864260055214, 30.598220028244768], [104.07847093917519, 30.597619213425432], [104.07799887038857, 30.597318806015764]];
  184. function showRoute() {
  185. iPoint_Route = 0;
  186. map.graphics.clear();
  187. layer_POI.setDefinitionExpression("CTYPEID=-1");
  188. //绘制轨迹线
  189. addLine(points_Route, map.spatialReference,blueColor);
  190. //绘制审批线路
  191. addLine(points_Route_Must, map.spatialReference, redColor);
  192. //启动车辆
  193. timer_Route = setInterval(flashRoute, 2000);
  194. }
  195. //
  196. //刷新轨迹位置
  197. function flashRoute() {
  198. map.graphics.clear();
  199. if (iPoint_Route < points_Route.length) {
  200. addPointGraphic(points_Route[iPoint_Route][0], points_Route[iPoint_Route][1], "images/mapIcon/huoche.png");
  201. iPoint_Route++;
  202. } else {
  203. clearInterval(timer_Route);
  204. }
  205. }
  206. //全图
  207. function zoomFull() {
  208. require(["esri/geometry/Point"], function (Point) {
  209. var pt = new Point({
  210. x: 102.1750010681153,
  211. y: 29.958719635009814,
  212. spatialReference: map.spatialReference
  213. });
  214. map.centerAndZoom(pt, 5);
  215. });
  216. }
  217. //放大
  218. function zoomOut() {
  219. var zm = map.getZoom() + 1;
  220. if (zm <20)
  221. map.setZoom(zm);
  222. }
  223. //缩小
  224. function zoomIn() {
  225. var zm = map.getZoom() - 1;
  226. if (zm > 4)
  227. map.setZoom(zm);
  228. }
  229. //-----------------------------------------城市定位------------------------------
  230. $("#ulCity li").click(function () {
  231. cityLocation(this.innerText);
  232. });
  233. var cityCenterData = [{ name: '成都市', coordX: 104.06464933797728, coordY: 30.66198193058378 },
  234. { name: '德阳市', coordX: 104.39616182267683, coordY: 31.128626242838894 },
  235. { name: '广汉市', coordX: 104.27720050416442, coordY: 30.98125495072465 },
  236. { name: '什邡市', coordX: 104.16931136018156, coordY: 31.128094096761312 },
  237. { name: '绵阳市', coordX: 104.71953866976015, coordY: 31.49196533513092 },
  238. { name: '广元市', coordX: 105.8411551951016, coordY: 32.432445904973584 },
  239. { name: '巴中市', coordX: 106.7548743597749, coordY: 31.857723620173256 },
  240. { name: '达州市', coordX: 107.48052099925064, coordY: 31.219486720196677 },
  241. { name: '自贡市', coordX: 104.77421082761674, coordY: 29.351811088249352 },
  242. { name: '泸州市', coordX: 105.43799099601415, coordY: 28.875347847910863 },
  243. { name: '宜宾市', coordX: 104.61442845147651, coordY: 28.77949224084179 },
  244. { name: '乐山市', coordX: 103.76477383864666, coordY: 29.570748332166442 },
  245. { name: '眉山市', coordX: 103.8388628847487, coordY: 30.057785987714666 },
  246. { name: '雅安市', coordX: 103.01869917051499, coordY: 29.994477273989844 },
  247. { name: '甘孜州', coordX: 101.96085326462626, coordY: 30.036053673370464 },
  248. { name: '阿坝州', coordX: 102.22195024516553, coordY: 31.90058805220809 },
  249. { name: '凉山州', coordX: 102.25959586068651, coordY: 27.883986689826066 },
  250. { name: '攀枝花市', coordX: 101.70856287209915, coordY: 26.581591822882732 },
  251. { name: '广安市', coordX: 106.6307129347292, coordY: 30.46058945850295 },
  252. { name: '南充市', coordX: 106.09258885235211, coordY: 30.80133728127757 },
  253. { name: '内江市', coordX: 105.05860193954454, coordY: 29.595999533171394 },
  254. { name: '资阳市', coordX: 104.63823762986025, coordY: 30.12372097172833 },
  255. { name: '遂宁市', coordX: 105.586908738787, coordY: 30.517752717983164 }]
  256. function cityLocation(cityName) {
  257. for (i = 0; i < cityCenterData.length; i++) {
  258. if (cityCenterData[i].name == cityName) {
  259. require(["esri/geometry/Point"], function (Point) {
  260. var pt = new Point({
  261. x: cityCenterData[i].coordX,
  262. y: cityCenterData[i].coordY,
  263. spatialReference: map.spatialReference
  264. });
  265. map.centerAndZoom(pt, 10);
  266. });
  267. }
  268. }
  269. }
  270. //-----------------------------------------城市定位 END------------------------------
  271. //
  272. //--------------------------------------热力图分析-------------------------------------
  273. function showHeatMap() {
  274. require([
  275.         "esri/InfoTemplate",
  276.         "esri/layers/FeatureLayer",
  277.         "esri/map",
  278.         "esri/renderers/HeatmapRenderer",
  279.         "dojo/domReady!"
  280. ],function (InfoTemplate, FeatureLayer, Map, HeatmapRenderer) {
  281. var infoTemplate = new InfoTemplate("${NAME}", "名称:${NAME}<br>类型:${TYPE}<br>地址:${ADDRESS}");
  282. var heatmapFeatureLayerOptions = {
  283. mode: FeatureLayer.MODE_SNAPSHOT,
  284. infoTemplate: infoTemplate,
  285. outFields: ["*"],
  286. definitionExpression: layer_POI.getDefinitionExpression()
  287. };
  288. var heatmapFeatureLayer = new FeatureLayer(layerUrl_POI, heatmapFeatureLayerOptions);
  289. var heatmapRenderer = new HeatmapRenderer();
  290. heatmapFeatureLayer.setRenderer(heatmapRenderer);
  291. map.addLayer(heatmapFeatureLayer);
  292. });
  293. }
  294. //--------------------------------------热力图分析 END-------------------------------------
  295. //--------------------------------------缓冲区分析-------------------------------------
  296. var isSetBufferCenter = false;
  297. function setBufferCenter() {
  298. isSetBufferCenter = true;
  299. }
  300. function executeBuffer() {
  301. var dis = $("#txtBufferDis").val();
  302. var bufferX= $("#txtBufferX").val();
  303. var bufferY = $("#txtBufferY").val();
  304. bufferX = parseFloat(bufferX);
  305. bufferY = parseFloat(bufferY);
  306. dis = parseFloat(dis);
  307. bufferAnalyst(bufferX, bufferY, dis);
  308. }
  309. function bufferAnalyst(ptX,ptY, bufferDistance) {
  310. require(["esri/geometry/Point", "esri/tasks/BufferParameters", "esri/SpatialReference", "dojo/dom", "esri/tasks/GeometryService", "esri/geometry/normalizeUtils" ],
  311. function (Point, BufferParameters, SpatialReference, dom, GeometryService, normalizeUtils) {
  312. if (geoService == null) {
  313. geoService = "init";
  314. esriConfig.defaults.geometryService = new GeometryService("http://123.146.170.78:6080/arcgis/rest/services/Utilities/Geometry/GeometryServer");
  315. // proxy 用于跨域
  316. esriConfig.defaults.io.proxyUrl = "/proxy/";
  317. esriConfig.defaults.io.alwaysUseProxy = false;
  318. }
  319. var params = new BufferParameters();
  320. var centerPoint = new Point(ptX, ptY, map.spatialReference);
  321. //params.geometries = [centerPoint];
  322. params.distances = [bufferDistance/100000];
  323. params.unit = 9102; //GeometryService.UNIT_SQUARE_FEET;
  324. params.bufferSpatialReference = map.spatialReference;
  325. params.outSpatialReference = map.spatialReference;
  326. normalizeUtils.normalizeCentralMeridian([centerPoint]).then(function (normalizedGeometries) {
  327. var normalizedGeometry = normalizedGeometries[0];
  328. if (normalizedGeometry.type === "polygon") {
  329. // 规范化多边形几何操作
  330. esriConfig.defaults.geometryService.simplify([normalizedGeometry], function (geometries) {
  331. params.geometries = geometries;
  332. // 进行缓冲操作
  333. esriConfig.defaults.geometryService.buffer(params, showBuffResult);// ShowBuffer is callback function
  334. });
  335. } else {
  336. params.geometries = [normalizedGeometry];
  337. esriConfig.defaults.geometryService.buffer(params, showBuffResult);
  338. }
  339. });
  340. });
  341. }
  342. function showBuffResult(bufferedGeometries) {
  343. require(["esri/graphic", "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "esri/Color", "dojo/_base/array"], function (Graphic, SimpleFillSymbol, SimpleLineSymbol, Color, array) {
  344. // 设置缓冲区显示样式
  345. var symbol = new SimpleFillSymbol(
  346. SimpleFillSymbol.STYLE_SOLID,
  347. new SimpleLineSymbol(
  348. SimpleLineSymbol.STYLE_SOLID,
  349. new Color([255, 0, 0, 0.65]), 2),
  350. new Color([255, 0, 0, 0.35])
  351. );
  352. // dojo 数组遍历
  353. array.forEach(bufferedGeometries, function (geometry) {
  354. bufferGeometry = geometry;
  355. map.setExtent(geometry.getExtent().expand(3));
  356. // 显示地图绘制样式
  357. var graphic = new Graphic(geometry, symbol);
  358. map.graphics.add(graphic);
  359. });
  360. });
  361. }
  362. //--------------------------------------缓冲区分析 END-------------------------------------
  363. //--------------------------------------应急事件处置-------------------------------------
  364. function eventHandle() {
  365. require(["esri/geometry/Point", "esri/tasks/BufferParameters", "esri/SpatialReference", "dojo/dom", "esri/tasks/GeometryService", "esri/geometry/normalizeUtils" ],
  366. function (Point, BufferParameters, SpatialReference, dom, GeometryService, normalizeUtils) {
  367. showEventPoint(104.06464933797728, 30.66198193058378);
  368. var where = "CTYPEID in (11,12,13,14)";
  369. layer_POI.setDefinitionExpression(where);
  370. bufferAnalyst(104.06464933797728, 30.66198193058378, 1000);
  371. });
  372. }
  373. function showEventPoint(ptX, ptY) {
  374. require(["esri/symbols/PictureMarkerSymbol", "esri/graphic", "esri/geometry/Point"
  375. ], function (PictureMarkerSymbol, Graphic, Point) {
  376. map.graphics.clear();
  377. var centerPoint = new Point(ptX, ptY, map.spatialReference);
  378. //定位点符号
  379. var symbol_Point = new PictureMarkerSymbol('images/mapIcon/event.png', 32, 32);
  380. map.graphics.add(new Graphic(centerPoint, symbol_Point));
  381. });
  382. }
  383. //--------------------------------------应急事件处置 END-------------------------------------
  384. //
  385. //-------------------------------------显示危化品生命周期-------------------------------
  386. function showLife() {
  387. clearAll();
  388. layer_SC.setVisibleLayers([0, 2]);
  389. require(["esri/geometry/Point"], function (Point) {
  390. var pt = new Point({
  391. x: 104.021,
  392. y: 30.661,
  393. spatialReference: map.spatialReference
  394. });
  395. map.centerAndZoom(pt, 10);
  396. });
  397. clearInterval(timer_Route);
  398. }
  399. function clearAll() {
  400. layer_SC.setVisibleLayers([]);
  401. layer_POI.setVisibility(false);
  402. map.graphics.clear();
  403. }