如何在北极或南极下方的灰色区域阻止谷歌地图 api v3 平移? [英] How to block google maps api v3 panning in the gray zone over north pole or under south pole?

查看:20
本文介绍了如何在北极或南极下方的灰色区域阻止谷歌地图 api v3 平移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用谷歌地图 v3 javascript API 我找不到阻止地图在北极或南极下平移的方法.作为此页面上的嵌入地图示例:https://developers.google.com/maps/documentation/embed/guide具有相同的行为,随着世界视图缩小和向北平移,将视图带入一个完整的灰色区域.

Using google maps v3 javascript API i cannot find a way to block the panning of the map over the north pole or under the south pole. As an example embedded maps on this page: https://developers.google.com/maps/documentation/embed/guide has the same behaviour, zooming out with the world view and panning north bring the view in a complete gray area.

如何像在官方网站 http://maps.google.it 上所做的那样进行预防?

How to prevent like it's done on official site http://maps.google.it ?

推荐答案

使用属性限制"为我工作:

Working for me with the attribute "restriction":

new google.maps.Map(document.getElementById('#mapCanvas'), {
  zoom: 2,
  center: {lat: 0, lng: 0},
  tilt: 0,
  restriction: {
    latLngBounds: {north: 85, south: -85, west: -180, east: 180},
    strictBounds: true
  },
});

这篇关于如何在北极或南极下方的灰色区域阻止谷歌地图 api v3 平移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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