map.nvue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <view class="content">
  3. <map class="map" ref="map1" :controls="controls" :scale="scale" :longitude="location.longitude" :latitude="location.latitude"
  4. :show-location="showLocation" :enable-3D="enable3D" :rotate="rotate" :skew="skew" :show-compass="showCompass"
  5. :enable-overlooking="enableOverlooking" :enable-zoom="enableZoom" :enable-scroll="enableScroll"
  6. :enable-rotate="enableRotate" :enable-satellite="enableSatellite" :enable-traffic="enableTraffic" :markers="markers"
  7. :polyline="polyline" :circles="circles" :polygons="polygons" :include-points="includePoints"></map>
  8. <view class="line"></view>
  9. <uni-list class="scrollview">
  10. <uni-list-item :show-arrow="false" :show-switch="true" :switch-checked="enable3D" title="显示3D楼块" @switchChange="enableThreeD" />
  11. <uni-list-item :show-arrow="false" :show-switch="true" :switch-checked="showCompass" title="显示指南针" @switchChange="changeShowCompass" />
  12. <uni-list-item :show-arrow="false" :show-switch="true" :switch-checked="enableOverlooking" title="开启俯视" @switchChange="changeEnableOverlooking" />
  13. <uni-list-item :show-arrow="false" :show-switch="true" :switch-checked="enableZoom" title="是否支持缩放" @switchChange="changeEnableZoom" />
  14. <uni-list-item :show-arrow="false" :show-switch="true" :switch-checked="enableScroll" title="是否支持拖动" @switchChange="changeEnableScroll" />
  15. <uni-list-item :show-arrow="false" :show-switch="true" :switch-checked="enableRotate" title="是否支持旋转" @switchChange="changeEnableRotate" />
  16. <uni-list-item :show-arrow="false" :show-switch="true" :switch-checked="enableSatellite" title="是否开启卫星图" @switchChange="changeEnableSatellite" />
  17. <uni-list-item :show-arrow="false" :show-switch="true" :switch-checked="enableTraffic" title="是否开启实时路况" @switchChange="changeEnableTraffic" />
  18. </uni-list>
  19. </view>
  20. </template>
  21. <script>
  22. import uniList from '@/components/uni-list/uni-list.vue'
  23. import uniListItem from '@/components/uni-list-item/uni-list-item.vue'
  24. const testMarkers = [{
  25. id: 0,
  26. latitude: 39.989631,
  27. longitude: 116.481018,
  28. title: '方恒国际 阜通东大街6号',
  29. zIndex: '1',
  30. rotate: 0,
  31. width: 20,
  32. height: 20,
  33. anchor: {
  34. x: 0.5,
  35. y: 1
  36. },
  37. callout: {
  38. content: '方恒国际 阜通东大街6号',
  39. color: '#00BFFF',
  40. fontSize: 10,
  41. borderRadius: 4,
  42. borderWidth: 1,
  43. borderColor: '#333300',
  44. bgColor: '#CCFF99',
  45. padding: '5',
  46. display: 'ALWAYS'
  47. }
  48. },
  49. {
  50. id: 1,
  51. latitude: 39.9086920000,
  52. longitude: 116.3974770000,
  53. title: '天安门',
  54. zIndex: '1',
  55. iconPath: '/static/location.png',
  56. width: 40,
  57. height: 40,
  58. anchor: {
  59. x: 0.5,
  60. y: 1
  61. },
  62. callout: {
  63. content: '首都北京\n天安门',
  64. color: '#00BFFF',
  65. fontSize: 12,
  66. borderRadius: 2,
  67. borderWidth: 0,
  68. borderColor: '#333300',
  69. bgColor: '#CCFF11',
  70. padding: '1',
  71. display: 'ALWAYS'
  72. }
  73. }
  74. ];
  75. const testPolyline = [{
  76. points: [{
  77. latitude: 39.925539,
  78. longitude: 116.279037
  79. },
  80. {
  81. latitude: 39.925539,
  82. longitude: 116.520285
  83. }
  84. ],
  85. color: '#FFCCFF',
  86. width: 7,
  87. dottedLine: true,
  88. arrowLine: true,
  89. borderColor: '#000000',
  90. borderWidth: 2
  91. },
  92. {
  93. points: [{
  94. latitude: 39.938698,
  95. longitude: 116.275177
  96. },
  97. {
  98. latitude: 39.966069,
  99. longitude: 116.289253
  100. },
  101. {
  102. latitude: 39.944226,
  103. longitude: 116.306076
  104. },
  105. {
  106. latitude: 39.966069,
  107. longitude: 116.322899
  108. },
  109. {
  110. latitude: 39.938698,
  111. longitude: 116.336975
  112. }
  113. ],
  114. color: '#CCFFFF',
  115. width: 5,
  116. dottedLine: true,
  117. arrowLine: true,
  118. borderColor: '#CC0000',
  119. borderWidth: 3
  120. }
  121. ];
  122. const testPolygons = [{
  123. points: [{
  124. latitude: 39.781892,
  125. longitude: 116.293413
  126. },
  127. {
  128. latitude: 39.787600,
  129. longitude: 116.391842
  130. },
  131. {
  132. latitude: 39.733187,
  133. longitude: 116.417932
  134. },
  135. {
  136. latitude: 39.704653,
  137. longitude: 116.338255
  138. }
  139. ],
  140. fillColor: '#FFCCFF',
  141. strokeWidth: 3,
  142. strokeColor: '#CC99CC',
  143. zIndex: 11
  144. },
  145. {
  146. points: [{
  147. latitude: 39.887600,
  148. longitude: 116.518932
  149. },
  150. {
  151. latitude: 39.781892,
  152. longitude: 116.518932
  153. },
  154. {
  155. latitude: 39.781892,
  156. longitude: 116.428932
  157. },
  158. {
  159. latitude: 39.887600,
  160. longitude: 116.428932
  161. }
  162. ],
  163. fillColor: '#CCFFFF',
  164. strokeWidth: 5,
  165. strokeColor: '#CC0000',
  166. zIndex: 3
  167. }
  168. ];
  169. const testCircles = [{
  170. latitude: 39.996441,
  171. longitude: 116.411146,
  172. radius: 15000,
  173. strokeWidth: 5,
  174. color: '#CCFFFF',
  175. fillColor: '#CC0000'
  176. },
  177. {
  178. latitude: 40.096441,
  179. longitude: 116.511146,
  180. radius: 12000,
  181. strokeWidth: 3,
  182. color: '#CCFFFF',
  183. fillColor: '#FFCCFF'
  184. },
  185. {
  186. latitude: 39.896441,
  187. longitude: 116.311146,
  188. radius: 9000,
  189. strokeWidth: 1,
  190. color: '#CCFFFF',
  191. fillColor: '#CC0000'
  192. }
  193. ];
  194. const testIncludePoints = [{
  195. latitude: 39.989631,
  196. longitude: 116.481018,
  197. },
  198. {
  199. latitude: 39.9086920000,
  200. longitude: 116.3974770000,
  201. }
  202. ];
  203. module.exports = {
  204. components: {
  205. uniList,
  206. uniListItem
  207. },
  208. data() {
  209. return {
  210. location: {
  211. longitude: 116.3974770000,
  212. latitude: 39.9086920000
  213. },
  214. controls: [{
  215. id: 1,
  216. position: {
  217. left: 5,
  218. top: 180,
  219. width: 30,
  220. height: 30
  221. },
  222. iconPath: '/static/logo.png',
  223. clickable: true
  224. }],
  225. showLocation: false,
  226. scale: 13,
  227. showCompass: true,
  228. enable3D: true,
  229. enableOverlooking: true,
  230. enableOverlooking: true,
  231. enableZoom: true,
  232. enableScroll: true,
  233. enableRotate: true,
  234. enableSatellite: false,
  235. enableTraffic: false,
  236. polyline: [],
  237. markers: [],
  238. polygons: [],
  239. circles: [],
  240. includePoints: [],
  241. rotate: 0,
  242. skew: 0
  243. }
  244. },
  245. onLoad() {},
  246. methods: {
  247. changeScale() {
  248. this.scale = this.scale == 9 ? 15 : 9;
  249. },
  250. changeRotate() {
  251. this.rotate = this.rotate == 90 ? 0 : 90;
  252. },
  253. changeSkew() {
  254. this.skew = this.skew == 30 ? 0 : 30;
  255. },
  256. enableThreeD(e) {
  257. this.enable3D = e.value;
  258. },
  259. changeShowCompass(e) {
  260. this.showCompass = e.value;
  261. },
  262. changeEnableOverlooking(e) {
  263. this.enableOverlooking = e.value;
  264. },
  265. changeEnableZoom(e) {
  266. this.enableZoom = e.value;
  267. },
  268. changeEnableScroll(e) {
  269. this.enableScroll = e.value;
  270. },
  271. changeEnableRotate(e) {
  272. this.enableRotate = e.value;
  273. },
  274. changeEnableSatellite(e) {
  275. this.enableSatellite = e.value;
  276. },
  277. changeEnableTraffic(e) {
  278. this.enableTraffic = e.value;
  279. }
  280. }
  281. }
  282. </script>
  283. <style>
  284. .content {
  285. flex: 1;
  286. }
  287. .map {
  288. width: 750rpx;
  289. height: 250px;
  290. background-color: #f0f0f0;
  291. }
  292. .line {
  293. height: 4px;
  294. }
  295. .scrollview {
  296. flex: 1;
  297. }
  298. </style>