[英]google map small controls
I got a very small map (180x120) but I still want people to be able to zoom in and out.我有一个非常小的 map (180x120),但我仍然希望人们能够放大和缩小。 How to display only the + and - on the map?
如何在map上只显示+和-?
I'm on Gmap v3.我在使用 Gmap v3。
I searched and don't find anything on google map help, maybe I didn't search correctly.我在谷歌 map 帮助上搜索并没有找到任何内容,也许我没有正确搜索。
Thanks谢谢
You can disable the default user interface and enable just the zoom buttons - 您可以禁用默认用户界面,而仅启用缩放按钮-
function initialize() {
var myOptions = {
zoom: 4,
center: new google.maps.LatLng(-33, 151),
panControl: false,
scaleControl: true,
zoomControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
}
See - http://code.google.com/apis/maps/documentation/javascript/controls.html#DefaultUI for more information. 有关更多信息,请参见-http://code.google.com/apis/maps/documentation/javascript/controls.html#DefaultUI 。
The controls shown on the map by default depend on the size of map. 默认情况下 ,地图上显示的控件取决于地图的大小。 However, you can turn off (or re-position or change style of) most controls through map options .
但是,您可以通过地图选项关闭(或重新定位或更改其样式)大多数控件。
In your case, it seems like google maps show three controls for a 180x120px map. 就您而言,似乎Google地图显示了180x120px地图的三个控件。 You can turn off map type and street view controls which leaves the compact zoom control behind:
您可以关闭地图类型和街景控件,而将紧凑的缩放控件留在后面:
var myOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControl: false,
streetViewControl: false
};
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
Bit late to the party, but for anyone trying to do the same, this can be done: 参加聚会有点晚,但是对于任何尝试这样做的人,可以这样做:
mapOptions = {
zoom: 5,
center: new google.maps.LatLng( 53.737531, -5.240479 ),
disableDefaultUI: true,
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL,
position: google.maps.ControlPosition.LEFT_CENTER
};
See: https://developers.google.com/maps/documentation/javascript/examples/control-positioning 请参阅: https : //developers.google.com/maps/documentation/javascript/examples/control-positioning
According to Google Maps API documentation :根据谷歌地图 API 文档:
mapOptions = {
controlSize = 20
};
Where 20 is the size of the controls in pixels.其中 20 是以像素为单位的控件大小。
Default = 40默认 = 40
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.