谷歌地图缩小限制 [英] google map zoom out limit

查看:128
本文介绍了谷歌地图缩小限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在地图上设置缩小限制,目前可以缩小到超出我看到多个世界地图的位置:



JS:

  var map; 

var all_coor =<?php echo json_encode($ addresses); ?取代;
var dub =<?php echo json_encode($ testadd); ?取代;

函数initialize(){
var MainLatlng = new google.maps.LatLng(-74.337724,-49.69693);

var mapOptions = {
zoom:7,
center:new google.maps.LatLng(31.386692,-12.700747)
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);

var markerr = new google.maps.Marker({
position:MainLatlng,
map:map,
title:'Main',
动画:google.maps.Animation.DROP
});

(var t = 0,llen = dub.length; t
var marker = new google.maps.Marker({
position:new google.maps.LatLng(dub [t] ['lat'],dub [t] ['long']),
map:map,
title:dub [t] ['title']
});




$ b google.maps.event.addDomListener(window,'load',initialize);

HTML:

 < div id =map-containerstyle =height:500px;> 

< / div>

1.如何为地图设置缩小限制以正确呈现?

解决方案

它已被添加到api中,您可以直接在地图对象上设置该选项:

  map.setOptions({minZoom:5,maxZoom:15}); 

ref - https://developers.google.com/maps/documentation/javascript/reference#MapOptions


How do I set zoom out limit on the map, it currently lets me zoom out too far to the point that I see multiple world maps:

JS:

var map;

var all_coor = <?php echo json_encode($addresses); ?>;
var dub = <?php echo json_encode($testadd); ?>;

function initialize() {
var MainLatlng = new google.maps.LatLng(-74.337724,-49.69693);

  var mapOptions = {
    zoom: 7,
    center: new google.maps.LatLng(31.386692,-12.700747)
  };
  map = new google.maps.Map(document.getElementById('map-canvas'),
      mapOptions);

 var markerr = new google.maps.Marker({
      position: MainLatlng ,
      map: map,
      title: 'Main',
      animation: google.maps.Animation.DROP
  });

for (var t = 0, llen = dub.length; t < llen; t++) {

    var marker = new google.maps.Marker({
      position: new google.maps.LatLng(dub[t]['lat'], dub[t]['long']),
      map: map,
      title: dub[t]['title']
    });

}

}


google.maps.event.addDomListener(window, 'load', initialize);

HTML:

<div id="map-container" style="height: 500px;">
<div id="map-canvas" style="width: 100%; height: 100%"></div>
</div>

1.How can I set a zoom out limit for the map to render properly?

解决方案

It's been added to the api, you can just set that option directly on the map object:

  map.setOptions({ minZoom: 5, maxZoom: 15 });

ref - https://developers.google.com/maps/documentation/javascript/reference#MapOptions

这篇关于谷歌地图缩小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆