在Google Map API 3中突出显示美国的州和城市的边界 [英] Highlighting borders of state and cities of US in Google Map API 3
问题描述
我有一个场景,我需要在对地理编码进行地理编码之后突出显示边界并遮蔽一个州或城市(当我获得郎和拉特时)。
我怎么能做到这一点,我是否需要有一个城市的完整信息用多段线包围它?或者有没有一种地图API可以为我做到这一点。
真的。 Google不提供此功能。所以我们可以做什么...我们可以拥有国家边界的经纬度。我们必须自己绘制多边形。
我用这个 JS目的。并将其更改为Google地图对象( google.maps.LatLng
)。 例如:
var statesobj = {AK:[new google.maps.LatLng(70.0187,-141.0205),
new google.maps .LatLng(70.1292,-141.7291),
google.maps.LatLng(70.4515,-144.8163)]}
所以,现在很容易。在这些经纬线上循环。你可以在美国的每个州都绘制多边形。
所以这就是我提出的解决方案。如果你们知道一些更好的想法做到这一点。请分享。
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).
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 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.
I used this JS object. And changed it to Google map object (google.maps.LatLng
).
For example:
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屋!