weizhimap.nvue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view>
  3. <web-view class="mapbody" :src="webUrl"></web-view>
  4. </view>
  5. </template>
  6. <script>
  7. import api from "@/pages/api/api.js"
  8. export default {
  9. name:"weizhimap",
  10. props:{
  11. covers:'',
  12. height:0
  13. },
  14. data() {
  15. return {
  16. webUrl: '',
  17. latitude:0,
  18. longitude:0,
  19. marker:'',
  20. markImage:'/static/images/dizhil@3x.png',
  21. };
  22. },
  23. onReady() {
  24. },
  25. watch:{
  26. covers(val){
  27. console.log('-----',val);
  28. this.markImage = val[0].iconPath;
  29. if(val[1]){
  30. this.webUrl = '/hybrid/html/maps/mapindex.html?sstate=0&&lat=' + val[0].latitude + '&lng=' + val[0].longitude+'&nlng='+val[1].longitude+'&nlat='+val[1].latitude;
  31. }
  32. else{
  33. this.webUrl = '/hybrid/html/maps/mapindex.html?sstate=0&&lat=' + val[0].latitude + '&lng=' + val[0].longitude+'&nlng=0&nlat=0';
  34. }
  35. console.log(this.webUrl)
  36. }
  37. },
  38. methods:{
  39. setLocat(latitude,longitude,f,t){
  40. this.latitude=latitude;
  41. this.longitude = longitude;
  42. this.marker=[{
  43. id:1,//控件id
  44. latitude: this.latitude,
  45. longitude: this.longitude,
  46. iconPath: this.markImage
  47. }];
  48. console.log(this.marker);
  49. return;
  50. var latlng = longitude+','+latitude;
  51. api('setLocat',{
  52. latlng:latlng,
  53. from:f,
  54. to:t
  55. },res=>{
  56. this.latitude=res.data.data.result[0].y;
  57. this.longitude = res.data.data.result[0].x;
  58. this.marker=[{
  59. latitude: this.latitude,
  60. longitude: this.longitude,
  61. iconPath: this.markImage
  62. }];
  63. },failc=>{
  64. //console.log('getadvertis----',failc)
  65. })
  66. },
  67. }
  68. }
  69. </script>
  70. <style>
  71. .mapbody{
  72. width: 750upx;
  73. height: 500rpx;
  74. background-color: aquamarine;
  75. }
  76. </style>