谷歌地图:无法在移动设备上滚动
我在我的网站上使用谷歌地图。它在所有浏览器中都工作得很好,但是我在移动设备上使用它时遇到问题:我无法滚动地图。我怀疑是由eventListener“点击”引起的,可能是这样吗?我将标记放置在用户单击的位置。
这是代码:
<script src="http://maps.google.com/maps/api/js?sensor=false&language=${Locale.getDefault()}" type="text/javascript"></script>
$(document).ready(function(){
createMap();
});
function createMap(){
geocoder = new google.maps.Geocoder();
infowindow = new google.maps.InfoWindow();
latlng = new google.maps.LatLng(55.783234,12.518363);
var myOptions = {
zoom: 7,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
marker = new google.maps.Marker();
google.maps.event.addListener(map, 'click', function(event) {
makeMarker(event.latLng, true);
});
}
I am using google maps on my web site. It works perfectly fine in all browsers, however I have problem using it on mobile: I cannot scroll the map. I am suspecting that it is caused by eventListener "click", might it be the case? I am placing marker in the place where user clicked.
Here is the code:
<script src="http://maps.google.com/maps/api/js?sensor=false&language=${Locale.getDefault()}" type="text/javascript"></script>
$(document).ready(function(){
createMap();
});
function createMap(){
geocoder = new google.maps.Geocoder();
infowindow = new google.maps.InfoWindow();
latlng = new google.maps.LatLng(55.783234,12.518363);
var myOptions = {
zoom: 7,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
marker = new google.maps.Marker();
google.maps.event.addListener(map, 'click', function(event) {
makeMarker(event.latLng, true);
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,在移动设备上使用 Google 地图并不是一个好主意。
It turns out it's not a very good idea to use Google Maps on a mobile device.