MainMap.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. 
  2. var layer_vector, layer_image, layer_POI, map,layer_SC;
  3. var layer_RouteLine, layer_RoutePoi;
  4. var graphicLayer_RouteLine;
  5. var redColor, blueColor;
  6. var geoService;
  7. var layerUrl_cd_vector = "http://125.70.9.221:8020/cdmap/rest/services/BASEMAP/Vector/MapServer";
  8. var layerUrl_cd_raster = "http://125.70.9.221:8020/cdmap/rest/services/BASEMAP/Raster/MapServer";
  9. var layerUrl_POI = "http://123.146.170.78:6080/arcgis/rest/services/SCPOI2/MapServer/1";
  10. var layerUrl_SC = "http://123.146.170.78:6080/arcgis/rest/services/SCPOI2/MapServer/";
  11. dojoConfig = {
  12. parseOnLoad: true,
  13. packages: [{
  14. name: 'tdlib',
  15. location: this.location.pathname.replace(/\/[^/]+$/, "") + "/js/tdlib"
  16. }]
  17. };
  18. require(["esri/map", "tdlib/TDTLayer", "tdlib/TDTRasterLayer", "tdlib/TDTAnnoLayer", "esri/layers/FeatureLayer","esri/InfoTemplate",
  19. "esri/geometry/Point", "esri/layers/GraphicsLayer", "esri/Color","esri/layers/ArcGISDynamicMapServiceLayer", "dojo/domReady!"],
  20. function (Map, TDTLayer, TDTRasterLayer, TDTAnnoLayer, FeatureLayer, InfoTemplate, Point, GraphicsLayer, Color, ArcGISDynamicMapServiceLayer) {
  21. var pt = new Point(104.06464933797728, 30.66198193058378);
  22. map = new Map("divMap", { logo: false, center: pt, zoom: 7 });
  23. layer_vector = new TDTLayer();
  24. layer_vector.id = "tianDiTu_vec";
  25. layer_vector.visible = false;
  26. map.addLayer(layer_vector);
  27. layer_image = new TDTRasterLayer();
  28. layer_image.id = "tianDiTu_img";
  29. layer_image.visible = false;
  30. map.addLayer(layer_image);
  31. layer_SC = new ArcGISDynamicMapServiceLayer(layerUrl_SC, {
  32. useMapImage: true,
  33. });
  34. layer_SC.setVisibleLayers([]);
  35. map.addLayer(layer_SC);
  36. var template_POI = {
  37. title: "${NAME}",
  38. content: "<table><tr>" +
  39. "<td><ul><li>名称:${NAME}</li><li>类型:${CTYPE}</li><li>区域:${CITY}-${DISTRICT}</li><li>电话:${TEL}</li><li>地址:${ADDRESS}</li></ul></td>" +
  40. "<td><img src='${PIC}' style='width:100%;height:100%' /></td></t></table>"
  41. };
  42. var infoTemplate_POI = new InfoTemplate(template_POI);
  43. layer_POI = new FeatureLayer(layerUrl_POI,{
  44. definitionExpression: "CTYPE='1'",
  45. infoTemplate: infoTemplate_POI,
  46. outFields: ["*"]
  47. });
  48. map.addLayer(layer_POI);
  49. graphicLayer_RouteLine = new GraphicsLayer({ id: "graphicLayer_RouteLine" });
  50. map.addLayer(graphicLayer_RouteLine);
  51. map.on('click', function (event) {
  52. if (isSetBufferCenter) {
  53. $("#txtBufferX").val(event.mapPoint.x);
  54. $("#txtBufferY").val(event.mapPoint.y);
  55. showEventPoint(event.mapPoint.x, event.mapPoint.y);
  56. isSetBufferCenter = false;
  57. }
  58. //var txt = $("#txtCoord").val()+ '['+ event.mapPoint.x + ',' + event.mapPoint.y + ']'
  59. var txt = event.mapPoint.x + ',' + event.mapPoint.y;
  60. $("#txtCoord").val(txt);
  61. });
  62. showLayer('vector');
  63. //初始化颜色
  64. redColor = new Color([255, 0, 0]);
  65. blueColor = new Color([0, 0, 255]);
  66. }
  67. );
  68. function showLayer(layerType) {
  69. layer_image.setVisibility(false);
  70. layer_vector.setVisibility(false);
  71. switch (layerType) {
  72. case 'vector':
  73. layer_vector.setVisibility(true);
  74. break;
  75. case 'image':
  76. layer_image.setVisibility(true);
  77. break;
  78. }
  79. }
  80. function addressQuery() {
  81. var queryValue = $("#txtQuery").val();
  82. 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";
  83. $.ajax({
  84. url: queryUrl,
  85. success: function (data) {
  86. data = data.replace('dojo.io.script.jsonp_dojoIoScript4._jsonpCallback(', '');
  87. data = data.replace(');', '');
  88. var result = eval('(' + data + ')');
  89. alert(result.message.features.length);
  90. var txt = "";
  91. map.graphics.clear();
  92. //for (i = 0; i < result.message.features.length; i++) {
  93. // txt += result.message.features[i].attributes[3] + ',';
  94. // var feature = result.message.features[i];
  95. // var attr = { name: feature.attributes[3], type: feature.attributes[4], address: feature.attributes[8], pic: feature.attributes[10] };
  96. // addPoint(feature.attributes[1], feature.attributes[2], view.spatialReference, attr);
  97. //}
  98. txt = JSON.stringify(result.message.columns);
  99. txt = txt + JSON.stringify(result.message.features);
  100. $("#txtCoord").val(txt);
  101. }
  102. })
  103. }
  104. //添加点位
  105. function addPointGraphic(x, y, pic) {
  106. require(["esri/symbols/PictureMarkerSymbol", "esri/symbols/TextSymbol", "esri/geometry/Point", "esri/graphic"], function (PictureMarkerSymbol, TextSymbol, Point, Graphic) {
  107. var pt = new Point(x,y,map.spatialReference );
  108. var symbol = new PictureMarkerSymbol(pic,32,32);
  109. var ptGraphic = new Graphic(pt, symbol );
  110. map.graphics.add(ptGraphic);
  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. function flashRoute() {
  197. map.graphics.clear();
  198. if (iPoint_Route < points_Route.length) {
  199. addPointGraphic(points_Route[iPoint_Route][0], points_Route[iPoint_Route][1], "images/mapIcon/huoche.png");
  200. iPoint_Route++;
  201. } else {
  202. clearInterval(timer_Route);
  203. }
  204. }
  205. //全图
  206. function zoomFull() {
  207. require(["esri/geometry/Point"], function (Point) {
  208. var pt = new Point({
  209. x: 102.1750010681153,
  210. y: 29.958719635009814,
  211. spatialReference: map.spatialReference
  212. });
  213. map.centerAndZoom(pt, 5);
  214. });
  215. }
  216. //放大
  217. function zoomOut() {
  218. var zm = map.getZoom() + 1;
  219. if (zm <20)
  220. map.setZoom(zm);
  221. }
  222. //缩小
  223. function zoomIn() {
  224. var zm = map.getZoom() - 1;
  225. if (zm > 4)
  226. map.setZoom(zm);
  227. }
  228. //-----------------------------------------城市定位------------------------------
  229. $("#ulCity li").click(function () {
  230. cityLocation(this.innerText);
  231. });
  232. var cityCenterData = [{ name: '成都市', coordX: 104.06464933797728, coordY: 30.66198193058378 },
  233. { name: '德阳市', coordX: 104.39616182267683, coordY: 31.128626242838894 },
  234. { name: '广汉市', coordX: 104.27720050416442, coordY: 30.98125495072465 },
  235. { name: '什邡市', coordX: 104.16931136018156, coordY: 31.128094096761312 },
  236. { name: '绵阳市', coordX: 104.71953866976015, coordY: 31.49196533513092 },
  237. { name: '广元市', coordX: 105.8411551951016, coordY: 32.432445904973584 },
  238. { name: '巴中市', coordX: 106.7548743597749, coordY: 31.857723620173256 },
  239. { name: '达州市', coordX: 107.48052099925064, coordY: 31.219486720196677 },
  240. { name: '自贡市', coordX: 104.77421082761674, coordY: 29.351811088249352 },
  241. { name: '泸州市', coordX: 105.43799099601415, coordY: 28.875347847910863 },
  242. { name: '宜宾市', coordX: 104.61442845147651, coordY: 28.77949224084179 },
  243. { name: '乐山市', coordX: 103.76477383864666, coordY: 29.570748332166442 },
  244. { name: '眉山市', coordX: 103.8388628847487, coordY: 30.057785987714666 },
  245. { name: '雅安市', coordX: 103.01869917051499, coordY: 29.994477273989844 },
  246. { name: '甘孜州', coordX: 101.96085326462626, coordY: 30.036053673370464 },
  247. { name: '阿坝州', coordX: 102.22195024516553, coordY: 31.90058805220809 },
  248. { name: '凉山州', coordX: 102.25959586068651, coordY: 27.883986689826066 },
  249. { name: '攀枝花市', coordX: 101.70856287209915, coordY: 26.581591822882732 },
  250. { name: '广安市', coordX: 106.6307129347292, coordY: 30.46058945850295 },
  251. { name: '南充市', coordX: 106.09258885235211, coordY: 30.80133728127757 },
  252. { name: '内江市', coordX: 105.05860193954454, coordY: 29.595999533171394 },
  253. { name: '资阳市', coordX: 104.63823762986025, coordY: 30.12372097172833 },
  254. { name: '遂宁市', coordX: 105.586908738787, coordY: 30.517752717983164 }]
  255. function cityLocation(cityName) {
  256. for (i = 0; i < cityCenterData.length; i++) {
  257. if (cityCenterData[i].name == cityName) {
  258. require(["esri/geometry/Point"], function (Point) {
  259. var pt = new Point({
  260. x: cityCenterData[i].coordX,
  261. y: cityCenterData[i].coordY,
  262. spatialReference: map.spatialReference
  263. });
  264. map.centerAndZoom(pt, 10);
  265. });
  266. }
  267. }
  268. }
  269. //-----------------------------------------城市定位 END------------------------------
  270. //--------------------------------------热力图分析-------------------------------------
  271. function showHeatMap() {
  272. require([
  273.         "esri/InfoTemplate",
  274.         "esri/layers/FeatureLayer",
  275.         "esri/map",
  276.         "esri/renderers/HeatmapRenderer",
  277.         "dojo/domReady!"
  278. ],function (InfoTemplate, FeatureLayer, Map, HeatmapRenderer) {
  279. var infoTemplate = new InfoTemplate("${NAME}", "名称:${NAME}<br>类型:${TYPE}<br>地址:${ADDRESS}");
  280. var heatmapFeatureLayerOptions = {
  281. mode: FeatureLayer.MODE_SNAPSHOT,
  282. infoTemplate: infoTemplate,
  283. outFields: ["*"],
  284. definitionExpression: layer_POI.getDefinitionExpression()
  285. };
  286. var heatmapFeatureLayer = new FeatureLayer(layerUrl_POI, heatmapFeatureLayerOptions);
  287. var heatmapRenderer = new HeatmapRenderer();
  288. heatmapFeatureLayer.setRenderer(heatmapRenderer);
  289. map.addLayer(heatmapFeatureLayer);
  290. });
  291. }
  292. //--------------------------------------热力图分析 END-------------------------------------
  293. //--------------------------------------缓冲区分析-------------------------------------
  294. var isSetBufferCenter = false;
  295. function setBufferCenter() {
  296. isSetBufferCenter = true;
  297. }
  298. function executeBuffer() {
  299. var dis = $("#txtBufferDis").val();
  300. var bufferX= $("#txtBufferX").val();
  301. var bufferY = $("#txtBufferY").val();
  302. bufferX = parseFloat(bufferX);
  303. bufferY = parseFloat(bufferY);
  304. dis = parseFloat(dis);
  305. bufferAnalyst(bufferX, bufferY, dis);
  306. }
  307. function bufferAnalyst(ptX,ptY, bufferDistance) {
  308. require(["esri/geometry/Point", "esri/tasks/BufferParameters", "esri/SpatialReference", "dojo/dom", "esri/tasks/GeometryService", "esri/geometry/normalizeUtils" ],
  309. function (Point, BufferParameters, SpatialReference, dom, GeometryService, normalizeUtils) {
  310. if (geoService == null) {
  311. geoService = "init";
  312. esriConfig.defaults.geometryService = new GeometryService("http://123.146.170.78:6080/arcgis/rest/services/Utilities/Geometry/GeometryServer");
  313. // proxy 用于跨域
  314. esriConfig.defaults.io.proxyUrl = "/proxy/";
  315. esriConfig.defaults.io.alwaysUseProxy = false;
  316. }
  317. var params = new BufferParameters();
  318. var centerPoint = new Point(ptX, ptY, map.spatialReference);
  319. //params.geometries = [centerPoint];
  320. params.distances = [bufferDistance/100000];
  321. params.unit = 9102; //GeometryService.UNIT_SQUARE_FEET;
  322. params.bufferSpatialReference = map.spatialReference;
  323. params.outSpatialReference = map.spatialReference;
  324. normalizeUtils.normalizeCentralMeridian([centerPoint]).then(function (normalizedGeometries) {
  325. var normalizedGeometry = normalizedGeometries[0];
  326. if (normalizedGeometry.type === "polygon") {
  327. // 规范化多边形几何操作
  328. esriConfig.defaults.geometryService.simplify([normalizedGeometry], function (geometries) {
  329. params.geometries = geometries;
  330. // 进行缓冲操作
  331. esriConfig.defaults.geometryService.buffer(params, showBuffResult);// ShowBuffer is callback function
  332. });
  333. } else {
  334. params.geometries = [normalizedGeometry];
  335. esriConfig.defaults.geometryService.buffer(params, showBuffResult);
  336. }
  337. });
  338. });
  339. }
  340. function showBuffResult(bufferedGeometries) {
  341. require(["esri/graphic", "esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "esri/Color", "dojo/_base/array"], function (Graphic, SimpleFillSymbol, SimpleLineSymbol, Color, array) {
  342. // 设置缓冲区显示样式
  343. var symbol = new SimpleFillSymbol(
  344. SimpleFillSymbol.STYLE_SOLID,
  345. new SimpleLineSymbol(
  346. SimpleLineSymbol.STYLE_SOLID,
  347. new Color([255, 0, 0, 0.65]), 2),
  348. new Color([255, 0, 0, 0.35])
  349. );
  350. // dojo 数组遍历
  351. array.forEach(bufferedGeometries, function (geometry) {
  352. bufferGeometry = geometry;
  353. map.setExtent(geometry.getExtent().expand(3));
  354. // 显示地图绘制样式
  355. var graphic = new Graphic(geometry, symbol);
  356. map.graphics.add(graphic);
  357. });
  358. });
  359. }
  360. //--------------------------------------缓冲区分析 END-------------------------------------
  361. //--------------------------------------应急事件处置-------------------------------------
  362. function eventHandle() {
  363. require(["esri/geometry/Point", "esri/tasks/BufferParameters", "esri/SpatialReference", "dojo/dom", "esri/tasks/GeometryService", "esri/geometry/normalizeUtils" ],
  364. function (Point, BufferParameters, SpatialReference, dom, GeometryService, normalizeUtils) {
  365. showEventPoint(104.06464933797728, 30.66198193058378);
  366. var where = "CTYPEID in (11,12,13,14)";
  367. layer_POI.setDefinitionExpression(where);
  368. bufferAnalyst(104.06464933797728, 30.66198193058378, 1000);
  369. });
  370. }
  371. function showEventPoint(ptX, ptY) {
  372. require(["esri/symbols/PictureMarkerSymbol", "esri/graphic", "esri/geometry/Point"
  373. ], function (PictureMarkerSymbol, Graphic, Point) {
  374. map.graphics.clear();
  375. var centerPoint = new Point(ptX, ptY, map.spatialReference);
  376. //定位点符号
  377. var symbol_Point = new PictureMarkerSymbol('images/mapIcon/event.png', 32, 32);
  378. map.graphics.add(new Graphic(centerPoint, symbol_Point));
  379. });
  380. }
  381. //--------------------------------------应急事件处置 END-------------------------------------
  382. //-------------------------------------显示危化品生命周期-------------------------------
  383. function showLife() {
  384. clearAll();
  385. layer_SC.setVisibleLayers([0, 2]);
  386. require(["esri/geometry/Point"], function (Point) {
  387. var pt = new Point({
  388. x: 104.021,
  389. y: 30.661,
  390. spatialReference: map.spatialReference
  391. });
  392. map.centerAndZoom(pt, 10);
  393. });
  394. clearInterval(timer_Route);
  395. }
  396. function clearAll() {
  397. layer_SC.setVisibleLayers([]);
  398. layer_POI.setVisibility(false);
  399. map.graphics.clear();
  400. }