SoFunction
Updated on 2025-04-05

Vue uses Gaode Map to implement code based on coordinate positioning points

Preface

In the project, you need to write down your own implementation process based on coordinate positioning. Without saying much nonsense, please add the code

text

<script>
var map,marker;
export default {
  data(){
    return{
      arriveCoor:[108.947025,34.2613255],//Coordinate points      arrive:"",//Location information    }
     
  },
  mounted() {   
    mapDraw(),
    mapCoor()
  },
  methods:{
     mapDraw(arriveCoor){
     map = new ('map-location', {  //map-location is the id of the map div embedded       resizeEnable: true, //Whether to monitor the size changes of map containers       zoom:16, //Initialize the map hierarchy       center: arriveCoor //Initialize the center point of the map     });
     // Position point     (arriveCoor);
  },
  // Instantiate point mark  addMarker(arriveCoor) {
    var _this = this;
    marker = new ({
      icon: "", //Picture ip      imageSize: "20px",
      position: arriveCoor,
      offset: new (-13, -30),
      // Set whether it can be dragged or not      draggable: true,
      cursor: 'move',
      // Set drag and drop effect      raiseOnDrag: true
    });
    (map);
  },
  // Query the coordinates  mapCoor(lnglatXY){
var _this = this;
('',function() {//Callback functionvar geocoder = new ({});
(lnglatXY, function (status, result) {
if (status === 'complete' &&  === 'OK') {
//Available valid address information:_this.arrive = ;
else {
_this.arrive = "No location yet";
}
});
})
},
}
</script> 

Summarize

The above is the implementation code of vue using Gaode map based on coordinate positioning points introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message. The editor will reply to everyone in time!