| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <template>
- <view>
- <map id="map" class="mapbody" :style="'height:'+height+'rpx;'" scale="18" show-location="true" :latitude="latitude" :longitude="longitude" :markers="marker">
- </map>
- </view>
- </template>
- <script>
- import api from "@/pages/api/api.js"
- export default {
- name:"weizhimap",
- props:{
- covers:'',
- height:0
- },
- data() {
- return {
- latitude:0,
- longitude:0,
- marker:'',
- markImage:'/static/images/dizhil@3x.png',
- };
- },
- onReady() {
-
- },
- watch:{
- covers(val){
- console.log('-----',val);
- this.markImage = val[0].iconPath;
- setTimeout(()=>{
- this.setLocat(val[0].latitude,val[0].longitude,1,3);
- },500)
-
- }
- },
- methods:{
-
- setLocat(latitude,longitude,f,t){
- this.latitude=latitude;
- this.longitude = longitude;
- this.marker=[{
- id:1,//控件id
- latitude: this.latitude,
- longitude: this.longitude,
- iconPath: this.markImage
- }];
- console.log(this.marker);
- return;
- var latlng = longitude+','+latitude;
-
- api('setLocat',{
- latlng:latlng,
- from:f,
- to:t
- },res=>{
- this.latitude=res.data.data.result[0].y;
- this.longitude = res.data.data.result[0].x;
- this.marker=[{
- latitude: this.latitude,
- longitude: this.longitude,
- iconPath: this.markImage
- }];
- },failc=>{
- //console.log('getadvertis----',failc)
- })
- },
- }
- }
- </script>
- <style>
- .mapbody{
- width: 750upx;
- height: 400rpx;
- }
- </style>
|