이 내 VUE의 JS 스크립트는 아약스 요청을 사용하여 JSON 데이터를 얻을 수 있습니다ajax 요청으로 얻은 json 데이터로 vue js를 사용하여 Google지도에서 위도와 경도를 표시하는 방법은 무엇입니까?
<script>
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');
}
});
})
},
}) </script>
<script>
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))
});
}
};
</script>
<style scoped>
.google-map {
width: 800px;
height: 600px;
margin: 0 auto;
background: gray;
}
</style>
내가 catch되지 않은 구문 에러와 같은 오류를 얻을입니다 : 예기치 않은 토큰 수출 .. 내가 어떻게 같은 문제를 해결하기 위해 어떤 생각을받지하고 있습니다. 나를
해결하는 데 도움이 제발이 모든 JSON 데이터
<div class="m-single-article" id="feed">
<p>{{details.bussinessName}}</p>
<p>{{details.pid}}</p>
<p v-for="inv in details.inventory">{{inv}}</p>
<p v-for="sub in details.sub_category">{{sub}}</p>
<div class="google-map" :id="mapName"></div>
</div>
를 표시하는 내 HTML 코드입니다하지만 점점 오류입니다. 아무도 내 문제를 해결할 수 있도록 도와주세요. 위도와 경도를 Google지도에 표시하려면 어떻게해야합니까? 나는 vue js의 초보자입니다. 이 문제를 해결하도록 도와주세요.
Google지도 API를 사용하여 동일한 문제를 해결할 다른 방법이 있습니까? https://jsfiddle.net/kzc26bgs/1/
는'() {'설치 나 구글 맵을 추가하지 않고 솔루션 내 JS 바이올린 링크를 가지고 도와주세요입니까? 'mounted : function() {'대신 –
shuksin.ivan, 유효한 자바 스크립트입니다. @coder, 단일 파일 구성 요소 및/또는 모듈 번들을 사용하고 있습니까? –
위도와 경도가 올지를 알리거나 말해주지 않을 것이다 – jeevanswamy21