在 Google Map API 3 中突出显示美国州和城市的边界 [英] Highlighting borders of state and cities of US in Google Map API 3

查看:26
本文介绍了在 Google Map API 3 中突出显示美国州和城市的边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个场景,在对它进行地理编码后(当我得到 lang 和 lat 时),我必须突出显示边界和阴影.

I have a scenario where I have to highlight borders and shade a state or city after geocoding it (when I got the lang and lat).

我该怎么做,我需要有一个城市的完整信息才能用折线包围它吗?或者地图 API 有没有办法帮我做到这一点.

How can I do this, do I need to have a complete information of a city to surround it with polylines? Or is there a way that map API can do this for me.

推荐答案

True.Google 不提供此功能.那么我们可以做什么......我们可以拥有国家边界的纬度/经度.我们必须自己绘制多边形.

True. Google does not provide this feature. So what we can do... we can have the lat/long of the borders of the state. And we have to draw polygons ourselves.

我使用了 this JS 对象.并将其更改为 Google 地图对象 (google.maps.LatLng).

I used this JS object. And changed it to Google map object (google.maps.LatLng).

例如:

var statesobj = {"AK": [new google.maps.LatLng(70.0187, -141.0205),
new google.maps.LatLng(70.1292, -141.7291),
new google.maps.LatLng(70.4515, -144.8163)]}

所以,现在很容易.循环这些经纬度.您可以在美国的每个州绘制多边形.

So, it's easy now. Loop on these lat/longs. And you can draw the polygons on every state of US.

这就是我想出的解决方案.如果你们知道一些更好的主意去做.请分享.

So this is the solution I came up. If you guys know some better idea to do it. Please share.

这篇关于在 Google Map API 3 中突出显示美国州和城市的边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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