K
K
kentos2019-01-31 10:25:16
Vue.js
kentos, 2019-01-31 10:25:16

How to pass value?

Hello, how to output from this method to the date, currentCoords

mapCreated: function ($map) {
                let pointOnMap = new ymaps.Placemark([55.7204,37.6200], {}, {
                    draggable: true
                });

                $map.geoObjects.add(pointOnMap);
                this.map = $map;

                let coords = [55.7204,37.6200]

                pointOnMap.events.add("dragend", function (e) {
                    let coords = this.geometry.getCoordinates();
                    let currentCoords = coords[1].toFixed(6) + ',' + coords[0].toFixed(6);
                }, pointOnMap);
            },

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
alex, 2019-01-31
@kentos

write this at the beginning of the method:

mapCreated: function ($map) {
  const _this = this;
//   далее идет код
}

then change let currentCoordsto_this.currentCoords
in the end it should be like this:
mapCreated: function ($map) {
  const _this = this
  
  let pointOnMap = new ymaps.Placemark([55.7204,37.6200], {}, {
    draggable: true
  });
  
  $map.geoObjects.add(pointOnMap);
  this.map = $map;
  
  let coords = [55.7204,37.6200]
  
  pointOnMap.events.add("dragend", function (e) {
    let coords = this.geometry.getCoordinates();
    _this.currentCoords = coords[1].toFixed(6) + ',' + coords[0].toFixed(6);
  }, pointOnMap);
}

N
nvdfxx, 2019-01-31
@nvdfxx

this.dataCurrentCoords = currentCoords, no?

J
Joss Nix, 2019-01-31
@Jossnix

replace
on the
Provided that currentCoords is declared in data

data() {
    return {
        currentCoords: ''
    ...    
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question