【发布时间】:2018-09-25 13:20:34
【问题描述】:
我正在尝试在 VueJS 中使用谷歌地图 API 显示街景全景图 我关注了谷歌地图文档https://developers.google.com/maps/documentation/javascript/examples/streetview-simple?hl=fr,这是模板部分:
<div id="map"></div>
<div id="pano"></div>
这是脚本部分:
mounted() {
var fenway = { lat: 42.345573, lng: -71.098326 };
var latlng = new google.maps.LatLng(42.345573, -71.098326);
map = new google.maps.Map(document.getElementById('map'), {
center: latlng,
zoom: 14
});
var panorama = new google.maps.StreetViewPanorama(
document.getElementById("pano"),
{
position: fenway,
pov: {
heading: 34,
pitch: 10
}
}
);
map.setStreetView(panorama);
}
我在 index.html 中提到过这个
<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY">
</script>
【问题讨论】:
标签: javascript google-maps vue.js vuejs2 google-street-view