xkjyeah / vue-google-maps

Google maps component for vue with 2-way data binding
https://xkjyeah.github.io/vue-google-maps/
1.88k stars 475 forks source link

get address (geocoder) from Lat and Lng #449

Open saraMElsanan opened 6 years ago

saraMElsanan commented 6 years ago

i'm trying to make component to retrieve Lng and Lat from database and display maker ... the maker is draggable ... when the marker is dragged i want to show the address in info window ` export default { name: "AddMap", props: { address: { type: Object, required: false, default: "{ latitude: '24.774265' , longitude: '46.738586' }" }, }, data() { return { center: { lat: 24.774265, lng: 46.738586 }, markers: [ { position: {lat: 24.774265, lng: 46.738586} }, ], places: [], zoom: 8, currentPlace: null, newAddress: Array, place: null }; }, methods: { updateCoordinates(newAddress) { this.newAddress = { lat: newAddress.latLng.lat(), lng: newAddress.latLng.lng(), }; this.place = { lat: newAddress.geometry.location.latLng.lat(), lng: newAddress.geometry.location.latLng.lng() }; var latitude = newAddress.latLng.lat(); var longitude = newAddress.latLng.lng();

        console.log(latitude , longitude);
        console.log(place);

    },
},

};` the script work just fine but when i try to get the new location address .. I get error in console

app.js:13685 TypeError: Cannot read property 'location' of undefined

warlord0 commented 6 years ago

I'm doing something similar with the OS AddressBase database and lat, lng. I posted a snippet here that may help.

459