gpt4 book ai didi

javascript - 使用 API 获取 google map 的 map 类型

转载 作者:行者123 更新时间:2023-11-29 20:11:24 25 4
gpt4 key购买 nike

这是我的同事为启动 map 并使其正常工作而编写的代码。我有几个问题。

function mapstart(maptype,streetview,fulladdress){
streetdisplay = false;
$(function() {
addr = fulladdress;
bool = true;
$('#'+maptype).gmap3({
action: 'getLatLng',
address: fulladdress,
callback: function(result){
if (result){
$(this).gmap3({action: 'setCenter', args:[ result[0].geometry.location ]});
drawmap(maptype,streetview);
} else {
bool = false;
alert('Incorrect address so map cannot be drawn !');
}
}
});
$('#'+maptype).show().gmap3().css('border', '1px solid #000000');
});
}
function drawmap(temp,tempstreet){
if(bool == true){
$('#'+temp).gmap3({
action: 'addMarker',
address: addr,
marker:{},
map:{
center: true,
zoom: 14,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
});
$('#'+tempstreet).click(function(){
countmap++;
if (countmap%2 == 0)
streetdisplay = false;
else
streetdisplay = true;
$('#'+temp).gmap3({
action:'getStreetView',
callback:function(panorama){
var visible = panorama.getVisible();
if (visible) {
panorama.setVisible(false);
} else {
var map = $(this).gmap3('get');
panorama.setPosition(map.getCenter());
panorama.setPov({
heading: 265,
zoom:1,
pitch:0
});
panorama.setVisible(true);
}
}
});
});
} else {
$('#'+temp).gmap3;
}
$('#'+temp).show().gmap3().css('border', '1px solid #000000');
}

在页面的其他地方,我需要显示当前正在运行的 map 类型。有一个按钮可以在路线图和街景 View 之间切换。另一件事是我们正在将 map 加载到默认情况下应该隐藏的 div 中。但是当我们调用 mapstart(params) 时,它会显示 map 。我们希望 map 加载并隐藏,然后在我们显示该 div 并隐藏其他 div 时显示。目前我有它,所以您按下以显示 map div 的按钮会加载 map ,但我不想在每次按下按钮时都重新加载 map 。

最佳答案

关于javascript - 使用 API 获取 google map 的 map 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9587306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com