2016-09-01 3 views
-1

私のプロジェクトにはgoogle maps api v3を使用しています。ポリゴン座標を使用して地域をハイライトしています。しかし、私は15の領域を強調表示しており、各領域には100以上のポリゴン座標があります。私はすべての座標を対応するリージョンの名前で置き、HTMLページでそれらのリージョン名を使用できる別のファイルを作成する方法はありますか? ここに私のコード別のファイルからポリゴンをGoogleマップにリンクする方法api v3

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

緯度経度オブジェクトと状態名のメークアレイとパス

例として使用します。次に、ポリゴンパス

var kerala = new google.maps.Polygon({ 
map: map, 
paths: maharashtraArray 
}); 
としてこの配列を使用

var maharashtraArray = []; 

maharashtraArray.push(new google.maps.LatLng("latitude","longitude")) 

関連する問題