zhengkaixin 5 månader sedan
förälder
incheckning
ba38cfd69c
2 ändrade filer med 41 tillägg och 197 borttagningar
  1. 33 196
      components/SelectMap.vue
  2. 8 1
      pages/bindingHomePile/bindingHomePile.vue

+ 33 - 196
components/SelectMap.vue

@@ -4,8 +4,7 @@
 		<view id="container" :style="myStyle">
 			
 		</view>
-		<u-icon name="map-fill"  class="input-card"  style="" color="red" size="80"></u-icon>
-	
+		
 		<view class="botton">
 			<view style="margin-bottom: 20px;">{{address}}</view>
 			<button class="get" @click="okBtn">确认</button>
@@ -143,88 +142,7 @@
 					//error)
 				})
 			},
-			calculateDistance(startLngLat,endLngLat){
-				
-				
-				var _this = this;
-				//var endLngLat = [item.longitude,item.latitude];
-				return new Promise((resolve, reject) => {
-					AMap.plugin('AMap.Driving', function() {
-					  var driving = new AMap.Driving({
-						// 驾车路线规划策略,AMap.DrivingPolicy.LEAST_TIME是最快捷模式
-						policy: AMap.DrivingPolicy.LEAST_TIME
-					  })
-					   
-					 
-					  driving.search(startLngLat, endLngLat, function (status, result) {
-							 
-							resolve(result.routes[0])
-					  })
-					
-					})
-				})
-			 
-			},
-			calcDistances(startLngLat,endLst){
-				 
-				var _this = this;
-				if(startLngLat[0]&&startLngLat[1]){
-					for(let i=0;i< endLst.length;i++)
-					 {
-						 let item = endLst[i];
-						 let endLngLat = [item.longitude,item.latitude]
-					 	 //if(endLst[i].distance == null){
-							 var lnglat = new AMap.LngLat(startLngLat[0],startLngLat[1]);
-							 var myDistance = lnglat.distance(endLngLat);
-							 //_self.stationDetail.station.distance = myDistance/1000;
-							 //_self.stationDetail.station.time = myDistance/500;  
-							 endLst[i].distance = myDistance/1000.0;
-							 endLst[i].time = myDistance/500.0; 	
-							 
-						 /*}else{
-							 endLst[i].time = endLst[i].distance/500.0; 	
-						 }*/
-						 
-					}
-				}
-				
-				
-				
-			},
-			
-			setChargerList(sz){ 
-					if(this.AMap==null){
-						return
-					}
-					//this.getLocation();
-					for(var i in this.chargerList){
-						if(this.chargerList[i].marker){
-							this.chargerList[i].marker.setMap(null);
-						}
-						this.mapcharger.remove(this.chargerList[i]);
-					}
-					
-					this.chargerList=[]
-					for(var i in sz){
-						var ob=sz[i];
-						this.addCharger(ob);
-						
-						 
-					}
-					
-			},
-			myEmit(type,ob1,obj){
-				var _this=this;
-				console.log("myEmit")
-				AMap.event.addListener(ob1, 'click', function(e) {
-					console.log("myEmit2",type,ob1,obj)
-					_this.$emit('clickMap',{
-						type:type,
-						obj:obj
-					})			
-				})
-				
-			},
+		
 			setMyStyle(s){
 				this.myStyle=s;
 			},			 
@@ -251,7 +169,7 @@
 					this.mapcharger.setCenter([item.longitude,item.latitude]);
 					this.checkCenter(item);
 //					this.listenMove();
- 
+					debugger
 //					this.enableMove(true);
 					return true
 				}else{
@@ -261,39 +179,7 @@
 				}
 			},		
 			 
-			setPerson(ob,bl){
-				//'setPerson1'+JSON.stringify(ob))
-				if(this.AMap==null){
-					return
-				}
-//				//'setPerson2')
-				
-					this.info.longitude=ob.longitude
-					this.info.latitude=ob.latitude
-					if(!this.info.ob){
-						this.addPerson(ob)
-						 
-						
-						//this.info.ob.setMap(this.mapcharger);
-						////'setMap  xxx ')
-						//this.mapbus.setCenter([this.info.longitude,this.info.latitude]); //设置地图中心点
-						if(!bl){
-							let posCenter= [ this.info.longitude,this.info.latitude];
-//							//'center'+JSON.stringify(posCenter))
-							//this.mapcharger.setZoom(9)
-							//this.mapcharger.setCenter([112.28541,30.308354])
-							//this.mapcharger.setCenter([121.504919,31.351083])
-							this.mapcharger.setCenter(posCenter); //设置地图中心点
-							
-							
-						}
 			
-					}else{
-					//	this.info.ob.setPosition( [this.info.longitude,this.info.latitude]);
-					}
-				
-				
-			}, 
 			logMapInfo() {
 			  var posCenter = this.mapcharger.getCenter();
 //			  //'center'+JSON.stringify(posCenter));
@@ -321,85 +207,36 @@
 					
 					//_this.mapcharger.setMapStyle('amap://styles/macaron');
 					_this.mapcharger.setMapStyle('amap://styles/f9b17f73bb4576ab1894c29fe9d03c6c');
-
-					/*
-					new SimpleMarker({
-					            iconLabel: '2',
-					            //自定义图标节点(img)的属性
-					            iconStyle: {
-					
-					                src: '@/static/img/location.png',
-					                style: {
-					                    width: '20px',
-					                    height: '30px'
-					                }
-					            },
-					  //设置基点偏移
-								offset: new AMap.Pixel(-10, -30),
-					
-								map: map,
-								showPositionPoint: true,
-								position: lngLats[1],
-								zIndex: 200
-							});
-*/
-					 /*
-					_this.mapcharger.plugin('AMap.Geolocation', function () {
-					        var geolocation = new AMap.Geolocation({
-					            enableHighAccuracy: true,
-					            timeout: 10000,
-					            buttonOffset: new AMap.Pixel(10, 220),
-					            zoomToAccuracy: true,
-					            buttonPosition: 'RB'
-					        });
-					        _this.mapcharger.center = geolocation;
-					        _this.mapcharger.addControl(geolocation);//地图控件右下角显示当前位置
+					//
+					var img=require("@/assets/img/md-my_location@3x.png")
+					 // 创建一个自定义图标
+					    var icon = new AMap.Icon({
+					      size: new AMap.Size(40, 40), // 图标的大小
+					      image: img, // 图标的图片URL
+					      imageSize: new AMap.Size(40, 40) // 图片的实际大小
 					    });
-					
-					_this.mapcharger.plugin(["AMap.ToolBar"],function(){
-					    //加载工具条
-					    var tool = new AMap.ToolBar({
-							locate:true,
-							direction:false,
-							ruler:false,
-							liteStyle:true,
-							useNative:true,
-//							autoPosition:true,
-//							locationMarker:
-						});
-					    _this.mapcharger.addControl(tool);    
-					});*/
-					/*
-					_this.mapcharger.plugin(["AMap.ControlBar"],function(){
-					    var controlBar = new AMap.ControlBar({
-							showZoomBar:true,
-							showControlButton:true,
-							position:{top:'10px',right:'10px'}
-						})
-					    _this.mapcharger.addControl(controlBar)
-					});*/
+						  // 创建标记并将其添加到地图中心
+						    var marker = new AMap.Marker({
+						      position: _this.mapcharger.getCenter(), // 设置标记的坐标为地图的中心
+						      icon: icon, // 设置标记的图标
+						      map: _this.mapcharger // 将标记添加到地图
+						    });
+						
 					var clickHandler = function(e) {
 						_this.$emit('onClicked',e);
 						//'您在[ '+e.lnglat.getLng()+','+e.lnglat.getLat()+' ]的位置点击了地图!');
 					};
 					
-					 /*
-					var mapMovestart = function(){
-						//'movestart')
-					}
-					var mapMove = function(){
-						////'mapMove')
-					}
-					var mapMoveend = function(){
-						let pos = _this.logMapInfo();
-						 
-						_this.$emit('onMoveEnd',pos);
-					//						//'mapMoveend')
-					}
-					_this.mapMovestart = mapMovestart;
-					_this.mapMove = mapMove;
-					_this.mapMoveend = mapMoveend;
-										*/
+					 _this.mapcharger.on('moveend', function() {
+					      marker.setPosition(_this.mapcharger.getCenter()); // 更新标记位置为地图中心
+						var pos=_this.mapcharger.getCenter()
+						console.log(pos)
+						  _this.getPositionByLonLats({
+						  			 latitude:pos.lat,
+						  			 longitude : pos.lng
+						  })
+					  });
+					
 					_this.mapcharger.on('click', clickHandler); 
 					_this.$emit('onload')
 					//_this.addPosition();
@@ -414,9 +251,9 @@
 			removeMove(){
 				var _this = this;
 				//this.enabledMove = false;
-				_this.mapcharger.off('movestart', mapMovestart);
-				_this.mapcharger.off('mapmove', mapMove);
-				_this.mapcharger.off('moveend', mapMoveend); 
+				// _this.mapcharger.off('movestart', mapMovestart);
+				// _this.mapcharger.off('mapmove', mapMove);
+				// _this.mapcharger.off('moveend', mapMoveend); 
 				 
 								
 			}, 
@@ -442,9 +279,9 @@
 					_this.$emit('onMoveEnd',pos); 
 				}*/
 //				//'listenMove')
-				_this.mapcharger.on('movestart', mapMovestart);
-				_this.mapcharger.on('mapmove', mapMove);
-				_this.mapcharger.on('moveend',mapMoveend); 
+				// _this.mapcharger.on('movestart', mapMovestart);
+				// _this.mapcharger.on('mapmove', mapMove);
+				// _this.mapcharger.on('moveend',mapMoveend); 
 				 
 			},
 			navigate(startLngLat,endLngLat){

+ 8 - 1
pages/bindingHomePile/bindingHomePile.vue

@@ -441,6 +441,10 @@
 			
 					this.subForm.latitude = latitude;
 					this.subForm.longitude = longitude;
+					this.$refs.amap.setCenter({
+						longitude:longitude,
+						latitude:latitude
+					})
 					this.getPositionByLonLats()
 				
 				}).catch(error => {
@@ -492,7 +496,10 @@
 				if(process.env.NODE_ENV === "development"){
 					this.subForm.longitude= 112.276527,
 					this.subForm.latitude=30.306427,
-
+					this.$refs.amap.setCenter({
+						longitude:this.subForm.longitude,
+						latitude:this.subForm.latitude
+					})
 					this.getInfo("bind:20241230001")
 					this.getPositionByLonLats()
 				}else{