天天看点

<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 的意思

<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

在百度地图和google map中,建议用户使用上方的meta类型,我查找到了一些论坛中的讨论,原文如下:

I'm using the Google Maps JavaScript API V3 and the official examples always have you include this meta tag:

<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />

Most of the 3rd-party examples I've seen also do it. I wrote a plugin using it, though, and one of my users told me it's preventing him from being able to zoom in and out on his mobile device. I don't have a mobile device to test with, and none of my searches revealed any helpful information.

回答是:

On many devices (such as the iPhone), it prevents the user from using the browser's zoom. If you have a map and the browser does the zooming, then the user will see a big ol' pixelated image with huge pixelated labels. The idea is that the user should use the zooming provided by Google Maps. Not sure about any interaction with your plugin, but that's what it's there for.

大致意思是,google map中的图片是有固定大小和像素的,为了避免用户使用浏览器的放大缩小页面的功能改变map中图片的显示,如放大窗口(ctrl + scroll),会改变图片的显示,导致地图显示不正常。所以google map利用这个语句禁止用户利用浏览器放大缩小窗口,建议用户使用google map自己的放大缩小功能。

ps:这个功能是在移动设备上使用的。

继续阅读