如何将Google地图限制为特定城市? [英] How Do I Restrict A Google Map To Specific City?

查看:178
本文介绍了如何将Google地图限制为特定城市?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function initialize() {
    var mapOptions = {
        zoom: 6,
        center: new google.maps.LatLng(30.893379000000000000, 60.028060900000010000),
    };
    var coord;
    var map = new google.maps.Map(document.getElementById('map-canvas'),
        mapOptions);
google.maps.event.addDomListener(window, 'load', initialize);

推荐答案

在我看来,最简单的解决方案是检查如果纬度或经度坐标超出了您想要设置的边界,则将纬度或经度设置为最外侧坐标。例如,如果纬度> 40,然后将纬度设置为40,以防止用户继续前进。
It seems to me that the simplest solution would be to check for if the latitude or longitude coordinates have exceeded the boundaries you wish to set, then set the latitude or longitude to the outermost coordinate. For example, if latitude > 40, then set latitude to 40 as to prevent the user from continuing onward.


这篇关于如何将Google地图限制为特定城市?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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