Код: Выделить всё
new Vue({
el: '#feed' ,
data: {
details: [],
},
mounted() {
this.$nextTick(function() {
var self = this;
var id = window.location.href.split('=').pop()
console.log(id)
$.ajax({
url: "https://",
method: "GET",
dataType: "JSON",
success: function (e) {
if (e.status == 1) {
self.details = e.data;
console.log(e.data)
}
else
{
console.log('Error occurred');}
}, error: function(){
console.log('Error occurred');
}
});
})
},
})
export default {
name: 'google-map',
props: ['name'],
data: function () {
return {
mapName: this.name + "-map",
markerCoordinates: [{
latitude: 51.501527,
longitude: -0.1921837
}],
map: null,
bounds: null,
markers: []
}
},
mounted: function () {
this.bounds = new google.maps.LatLngBounds();
const element = document.getElementById(this.mapName)
const mapCentre = this.markerCoordinates[0]
const options = {
center: new google.maps.LatLng(mapCentre.latitude, mapCentre.longitude)
}
this.map = new google.maps.Map(element, options);
this.markerCoordinates.forEach((coord) => {
const position = new google.maps.LatLng(coord.latitude, coord.longitude);
const marker = new google.maps.Marker({
position,
map: this.map
});
this.markers.push(marker)
this.map.fitBounds(this.bounds.extend(position))
});
}
};
.google-map {
width: 800px;
height: 600px;
margin: 0 auto;
background: gray;
}
Я не знаю, как решить ту же проблему. Пожалуйста, помогите мне решить
Это мой HTML-код для отображения всех данных JSON
Код: Выделить всё
{{details.businessName}}
{{details.pid}}
{{inv}}
{{sub}}
Есть ли другой способ решить эту проблему с помощью API карт Google? Пожалуйста, помогите мне найти решение.
Моя ссылка на js-скрипт без добавления карт Google: https://jsfiddle.net/kzc26bgs/1/
Подробнее здесь: https://stackoverflow.com/questions/471 ... -data-obta