我正在为我的项目使用谷歌地图api v3,我正在使用一组多边形坐标来突出显示一个区域。但我突出显示15个区域,每个区域有100多个多边形坐标。有没有办法我可以创建另一个文件,我可以将所有坐标与相应的区域名称放在一起,我可以在我的html页面中使用这些区域名称。 这是我的代码
var kerala = new google.maps.Polygon({
map: map,
paths: [
new google.maps.LatLng(12.758232,74.86084),
new google.maps.LatLng(12.736801,75.014648),
new google.maps.LatLng(12.329269,75.432129),
new google.maps.LatLng(12.093039,75.794678),
new google.maps.LatLng(11.942601,75.959473),
/* n number of coordinates */
],
strokeColor: '#873600',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#873600',
fillOpacity: 0.5
});
但我想要这样的东西
var kerala = new google.maps.Polygon({
map: map,
paths: /* here i should give the name of a region, which will be defined with coordinates in another file */
});
有人请帮我这个,我甚至不知道如何定义那个多边形坐标文件,以及应该定义该文件的扩展名。
答案 0 :(得分:0)
使用latlng对象创建状态名称数组并用作路径
示例:强>
var maharashtraArray = [];
maharashtraArray.push(new google.maps.LatLng("latitude","longitude"))
然后将此数组用作多边形路径
var kerala = new google.maps.Polygon({
map: map,
paths: maharashtraArray
});