나는 과거 KML 파일을 사용하여 웹 페이지의 폴리곤을 오버레이했습니다.
나는 독서가 KML tutorials
- 는
- 이 KML은 구글 API에서
- 전화 KML 파일을 파일 만들기 데이터베이스에서 읽을 수있는 함수를 만듭니다 구글의 제안
KML는 당신을 제공하는 반면 모양을 오버레이하는 빠르고 쉬운 방법 인 Google은 표시되는 항목의 수를 제한합니다.
다음은 KML 접근 방식을 시작하는 데 도움이됩니다.
public ActionResult Kml()
{
DataAccess da = new DataAccess();
string cellColor = "0032FB";
string kml = @"<?xml version=""1.0"" encoding=""UTF-8""?>
<kml xmlns=""http://earth.google.com/kml/2.1"">
<Document>
<Style id="polygon">
<LineStyle>
<color>FF" + cellColor + @"</color>
</LineStyle>
<PolyStyle>
<color>44" + cellColor [email protected]"</color>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
</Style>
<name>some name</name>
<description>some des</description>
";
DataTable polygons;
foreach (DataRow polygon in polygons.Rows)
{
kml += @"
<Placemark>
<name>"somename @"</name>
<description><![CDATA[<p>some text</p>]]></description>" +
@"<styleUrl>#polygon</styleUrl>
<Polygon>
<extrude>1</extrude>
<altitudeMode>clampToSeaFloor</altitudeMode>
<outerBoundaryIs>
<LinearRing>
<coordinates>" +
polygon["Cell Limit Longitude West"].ToString() + "," + polygon["Cell Limit Latitude North"].ToString() + " " +
polygon["Cell Limit Longitude East"].ToString() + "," + polygon["Cell Limit Latitude North"].ToString() + " " +
polygon["Cell Limit Longitude East"].ToString() + "," + polygon["Cell Limit Latitude South "].ToString() + " " +
polygon["Cell Limit Longitude West"].ToString() + "," + polygon["Cell Limit Latitude South "].ToString() + " " +
polygon["Cell Limit Longitude West"].ToString() + "," + polygon["Cell Limit Latitude North"].ToString() + " " +
@"</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
";
}
kml += @"</Document>
</kml>";
byte[] data = Encoding.ASCII.GetBytes(kml);
return File(data, "application/vnd.google-earth.kml+xml", id);
}
자바 스크립트
var url = 'http://www.example.com/AppName/GMap/file.kml &rand=' + Math.random();
layer_paperCharts = new google.maps.KmlLayer(url);
if (loadedonce) {
layer_paperCharts.set('preserveViewport', true);
} else {
loadedonce = true;
}
layer_paperCharts.setMap(map);
구글 캐시 KML 파일이 주위에 얻을 것이다)를 인 Math.random (의 추가 때문에.
Fusion Tables에서 확인할 수도 있습니다. 그러나 데이터를 Google에 업로드해야합니다. 또한 Google은 제시된 데이터를 그룹화합니다. 하지만 SQL을 원한다면이 옵션을 사용할 수 없을 수도 있습니다.
필자는 이것이 다소 괴롭다는 것을 알고 있지만, 이와 같은 대답에서 USING 문을 올바르게 사용해야 함을 설명해야합니다. 특히이 사용 예에서는 객체를 적절하게 배치하지 않으면 메모리 누수가 발생할 수 있다고 생각합니다. – Wjdavis5