谷歌地图API-如何停止滚动(JavaScript)
Google Map API - How to Stop Scrolling (JavaScript)
我正试图停止在谷歌地图上滚动。我看过其他问题,大多数答案都说在地图选项中添加滚动条:false,但这并没有奏效。有人对此有什么建议吗?
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滚动脚本-在测试中激发,而不是在开发站点上
- 无锚点的JavaScript滚动页面
- 如何在使用函数document.write()打印最终结果后,使用Javascript滚动到页面顶部
- Javascript滚动到底,生成重复的请求
- Javascript滚动激活
- Javascript滚动并调整窗口大小
- HTML锚加Javascript滚动
- 使用iOS7的iPhone上未启动JavaScript滚动事件
- JavaScript滚动图片库在Chrome或IE中不起作用
- 如何用javascript滚动html中pdf对象元素的底部
- 没有按钮的Javascript滚动器有问题
- Javascript滚动和移动位置
- JavaScript滚动文本;t负载变量
- 带有转换比例错误的自定义JavaScript滚动条(jScrollPane)
- 创建新窗口时使用Javascript滚动条
- 使用Javascript滚动列表
- 如何在正文加载之前使用 javascript 滚动页面
- JavaScript 滚动到 y 位置
- 如何使用 JavaScript 滚动事件更改 HTML 输入
- 使用纯 Javascript 滚动到可滚动 DIV 中的元素