gpt4 book ai didi

javascript - Google map API - 如何停止滚动 (JavaScript)

转载 作者:行者123 更新时间:2023-12-03 10:26:02 25 4
gpt4 key购买 nike

我试图停止在 Google map 上滚动。我查看了其他问题,大多数答案都说将scrollwheel: false 放入您的 map 选项中,但这并没有起作用。有人对此有任何指示吗?

function initialize() {

var myLatlng = new google.maps.LatLng(51.843143, -2.643555),
map = new google.maps.Map(document.getElementById('map'), {
zoom: 12,
center: myLatlng
}),
infowindow = new google.maps.InfoWindow({
content: "<b>Paddle the Wye base</b>"
}),
marker = new google.maps.Marker({
position: myLatlng,
map: map,
title: "We are here!"
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});
infowindow.open(map, marker);

var accessPoint1 = new google.maps.LatLng(51.840913, -2.638603),
marker1 = new google.maps.Marker({
position: accessPoint1,
map: map,
title: "Access Point 1"
});
map.controls[google.maps.ControlPosition.TOP_LEFT].push($("#findButton")[0]);


function successCallback(position) {
var latlng = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude),

myOptions = {
zoom: 3,
center: latlng,
mapTypeControl: false,
scrollwheel: false,
navigationControlOptions: {
style: google.maps.NavigationControlStyle.SMALL
},
mapTypeId: google.maps.MapTypeId.ROADMAP
},
bounds = new google.maps.LatLngBounds(latlng);

bounds.extend(marker.getPosition());

map.setOptions(myOptions);

map.fitBounds(bounds);

new google.maps.Marker({
position: latlng,
map: map,
title: "You are here!",
icon: 'http://maps.gstatic.com/mapfiles/markers2/boost-marker-mapview.png'
});
}

function errorCallback() {
alert("I'm afraid your browser does not support geolocation.");
}

function findMe() {
$(this).hide();

if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(successCallback, errorCallback, {
timeout: 10000
});
} else {
alert("I'm afraid your browser does not support geolocation.");
}
}

$("#findButton").click(findMe);
}

google.maps.event.addDomListener(window, 'load', initialize);

最佳答案

我无法完全理解您的代码,但您必须在此处添加它:

var myLatlng = new google.maps.LatLng(51.843143, -2.643555),
map = new google.maps.Map(document.getElementById('map'), {
zoom: 12,
center: myLatlng,
--> scrollwheel: false
}),

关于javascript - Google map API - 如何停止滚动 (JavaScript),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29398547/

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