最近几天我在我的网站上遇到了一个问题。当试图在 map 上切换到街景 View 时 - 在街道上放下黄人后 - 我得到一个灰色屏幕(见屏幕截图)。 我的控制台(在 Chrome 上)显示此错误,在进行切换时弹出:
Uncaught TypeError: Cannot redefine property: Map at defineProperty () at pa (https://maps.googleapis.com/maps-api-v3/api/js/30/5/intl/en_gb/imagery_viewer.js:3:229) at https://maps.googleapis.com/maps-api-v3/api/js/30/5/intl/en_gb/imagery_viewer.js:7:1 at https://maps.googleapis.com/maps-api-v3/api/js/30/5/intl/en_gb/imagery_viewer.js:866:268
我过去也遇到过这个问题,但我通过降级我的谷歌地图版本解决了这个问题。 我的初始化映射:
function init_map() {
var myOptions = {
zoom: 4,
center: new google.maps.LatLng(48.632909,17.138672),
panControl: true,
zoomControl: true,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
position: google.maps.ControlPosition.TOP_RIGHT
},
scaleControl: true,
streetViewControl: true,
gestureHandling: 'greedy',
mapStreetViewControlOptions: {
position: google.maps.ControlPosition.RIGHT_TOP
},
overviewMapControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var gmap = new google.maps.Map(document.getElementById("gmap"), myOptions);
我之前使用的是 3.29,它运行良好,现在,我在使用 3.31 版时遇到了问题:
<script src="maps.google.com/maps/api/js?v=3.31&key=....."; type="text/javascript"></script>
最佳答案
我们遇到了完全相同的错误字符串,但在仅加载嵌入式 map 本身时看到了。看来我们正在另一个(现在未使用的)JS 文件中重新定义函数 Map()
,重命名此函数解决了这个问题。
我并不是完全靠自己得出这个结论,请参阅 Google Product Forums对于描述与您完全相同的问题的用户。
关于javascript - 街景错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48862257/