如何使用适用于 android 的谷歌地图 API 将地图限制在一个国家/地区 [英] how to restrict maps to only one country using google maps api for android

查看:32
本文介绍了如何使用适用于 android 的谷歌地图 API 将地图限制在一个国家/地区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 android 的 google 地图 api 完全陌生,我想知道是否可以将地图显示的区域限制在一个国家/地区.我的意思是我的目标用户仅在我自己的国家/地区,当应用程序逻辑仅在这个国家/地区时,向他们展示整个世界既没有用也没有逻辑.

I am totally new to google's maps api for android and I was wondering if it is possible to restrict the area the map is showing to one country only. I mean my target users are in my own country only and it is not useful nor logical to show them the whole world when the application logic is going to be only on this country.

有什么想法吗?

ps:如果在 google 的 api 中不可能,有没有办法用另一个提供地图服务的源的另一个 api 来做到这一点?

ps: if it is not possible in google's api,is there a way to do this with another api form another source which provides a mapping service?

推荐答案

如果您仍然感兴趣,现在可以使用 setLatLngBoundsForCameraTarget 方法将用户的平移限制到给定区域.

If you are still interested, now it's possible to restrict the user's panning to a given area using the setLatLngBoundsForCameraTarget method.

您需要更新 Play 服务的依赖项:

You will need to update the dependencies for your Play Services:

dependencies {
    compile 'com.google.android.gms:play-services:9.6.1'
}

这篇关于如何使用适用于 android 的谷歌地图 API 将地图限制在一个国家/地区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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