FenceInfo.cshtml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. @using MES.Production.Service;
  2. @using Central.Control.Domain;
  3. @using Ant.Service.Common;
  4. @using Ant.Service.Common.Enums;
  5. @using MES.Production.Entity;
  6. @model EntSYS_DISTRIBUTORS
  7. <!doctype html>
  8. <html>
  9. <head>
  10. <meta charset="utf-8">
  11. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  12. <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
  13. <title>经销商围栏信息</title>
  14. <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css" />
  15. <script src="http://webapi.amap.com/maps?v=1.3&key=fa36ec6323075f37020083ceffe8eb24"></script>
  16. <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
  17. <script src="http://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
  18. </head>
  19. <body>
  20. <div id="container"></div>
  21. <script>
  22. var map = new AMap.Map('container', {
  23. resizeEnable: true,
  24. center: [@Model.Theodolite],
  25. zoom: 13
  26. });
  27. var circle = new AMap.Circle({
  28. center: new AMap.LngLat("@Model.Theodolite.Split(',')[0]", "@Model.Theodolite.Split(',')[1]"),// 圆心位置
  29. radius: @(Model.FenceRadius/2), //半径
  30. strokeColor: "#ff0000", //线颜色
  31. strokeOpacity: 0.5, //线透明度
  32. strokeWeight: 3, //线宽
  33. fillColor: "#ff6699", //填充色
  34. fillOpacity: 0.1//填充透明度
  35. });
  36. //声明一个list
  37. var list = {
  38. "size": 4,
  39. "data": [
  40. { "x": 116.397428, "y": 39.921883 },
  41. { "x": 116.397428, "y": 39.920213 },
  42. { "x": 116.403322, "y": 39.922282 },
  43. { "x": 116.403322, "y": 39.920249 }
  44. ]
  45. }
  46. for (var j = 0, map; j < list.size; j++) {
  47. var myObj = list.data[j];
  48. var myLngLat = new AMap.LngLat(myObj.x, myObj.y);
  49. console.log(circle.contains(myLngLat));
  50. if (circle.contains(myLngLat)) {//如果点在圆内则输出
  51. var marker = new AMap.Marker({
  52. position: myLngLat,
  53. map: map
  54. });
  55. }
  56. }
  57. circle.setMap(map);//显示圆圈
  58. map.setFitView();//根据地图上添加的覆盖物分布情况,自动缩放地图到合适的视野级别
  59. AMapUI.loadUI(['overlay/SimpleInfoWindow'], function (SimpleInfoWindow) {
  60. var marker = new AMap.Marker({
  61. map: map,
  62. zIndex: 99999,
  63. offset: new AMap.Pixel(-5, -20),//相对于基点的位置
  64. //icon: new AMap.Icon({ //复杂图标
  65. // size: new AMap.Size(14, 20),//图标大小
  66. // image: "http://47.96.20.14:8086/Content/map/map-marker-icon.png", //大图地址
  67. //})
  68. //draggable: true, //是否可拖动
  69. iconStyle: {
  70. src: 'http://47.96.20.14:8086/Content/map/map-marker-icon.png',
  71. style: {
  72. width: '14px',
  73. height: '20px'
  74. }
  75. },
  76. });
  77. var infoWindow = new SimpleInfoWindow({
  78. infoTitle: '<strong>经销商地址:</strong>',
  79. infoBody: '<p class="my-desc"><strong>@Model.Address<br/></strong></p>',
  80. //基点指向marker的头部位置
  81. offset: new AMap.Pixel(0, -31)
  82. });
  83. function openInfoWin() {
  84. infoWindow.open(map, marker.getPosition());
  85. }
  86. //marker 点击时打开
  87. AMap.event.addListener(marker, 'click', function () {
  88. openInfoWin();
  89. });
  90. });
  91. </script>
  92. </body>
  93. </html>
  94. @*https:blog.csdn.net/dKnightL/article/details/74787775*@