天天看點

<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:這個功能是在移動裝置上使用的。

繼續閱讀