Javascript 如何将不同文件中的多边形链接到google maps api v3
我在我的项目中使用GoogleMapsAPIv3,我使用一组多边形坐标来突出显示一个区域。但我突出显示了15个区域,每个区域有100多个多边形坐标。有没有办法我可以创建另一个文件,我可以把所有的坐标与它们对应的地区的名称,我可以使用这些地区的名称在我的html页面。 这是我的密码Javascript 如何将不同文件中的多边形链接到google maps api v3,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,我在我的项目中使用GoogleMapsAPIv3,我使用一组多边形坐标来突出显示一个区域。但我突出显示了15个区域,每个区域有100多个多边形坐标。有没有办法我可以创建另一个文件,我可以把所有的坐标与它们对应的地区的名称,我可以使用这些地区的名称在我的html页面。 这是我的密码 var kerala = new google.maps.Polygon({ map: map, paths: [ new google.maps.LatLng(12.758232,74.86084), new goo
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 */
});
有人请帮我,我甚至不知道如何定义多边形坐标文件,以及该文件应该使用哪个扩展名来定义 使用latlng对象生成状态名称数组并用作路径 示例:
var maharashtraArray = [];
maharashtraArray.push(new google.maps.LatLng("latitude","longitude"))
然后将此数组用作多边形路径
var kerala = new google.maps.Polygon({
map: map,
paths: maharashtraArray
});