如何根据用户的选择将地图的焦点设置到特定国家/地区?
在我的应用程序中,用户试图查看给定国家/地区的活动数量。假设他想看到美国地区的所有活动,那么我应该如何将焦点集中在美国而不是全世界。
谢谢,
In my app user is trying to see the number of activity in a given country. Let's say if he wants to see all the activities in US region so how should i set the focus on US only and not on the whole world.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用以下方法:
并在任何情况下通过以下行调用此方法:
Use Following Method:
And Call this method through following line in any event:
您所要做的就是找出您希望地图以哪个坐标为中心,以及地图大小有多大,这样就可以了。我不确定是否有任何在线资源具有每个国家/地区的通用点,但您可以在谷歌上查找它们,并制作一个字典,其中包含每个国家/地区的所有中心点和尺寸,名称为国家是这些问题的关键。然后,当用户选择一个国家/地区时,您可以在字典中查找它,并将这些中心点和尺寸加载到地图中,这将显示该国家/地区。希望有帮助!
All you have to do is figure out the coordinates that you want the map to centre on, and how large the map size is, and that will work. I'm not sure if there are any online resources which have generic points for each country, but you could look them up on google, and the make a dictionary which holds all of those centre points and sizes for each country, with the name of the country being the key for those points. Then, when the user selects a country, you look it up in the dictionary, and load those centre points and sizes into your map, and that will display that country. Hope that helps!