2012-05-24 6 views
1

KML 파일을 다운로드하여 Google지도 API를 사용하는 프로젝트에로드하려고했습니다.Google지도 API에 KML 파일로드

이 KML을로드 할 때 결과가 표시되지 않습니다. 다른 KML 파일도 작동합니다.

<!DOCTYPE html> 
<html> 
<head> 
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
<title>Google Maps JavaScript API v3 Example: KmlLayer KML</title> 
<link href="/maps/documentation/javascript/examples/default.css" rel="stylesheet"  type="text/css" /> 
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?  sensor=false"></script> 
<script type="text/javascript" src="http://geoxml3.googlecode.com/svn/branches/polys/geoxml3.js"></script> 
<style type="text/css"> 
    html { height: 100% } 
    body { height: 100%; margin: 0; padding: 0 } 
    #map_canvas { height: 100% } 
</style> 

<script type="text/javascript"> 
function initialize() { 
var chicago = new google.maps.LatLng(41.875696,-87.624207); 
var myOptions = { 
zoom: 2, 
center: chicago, 
mapTypeId: google.maps.MapTypeId.ROADMAP } 
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 
    var geoXml = new geoXML3.parser({map: map, singleInfoWindow: true}); 
    geoXml.parse('doc2.kml'); } 
</script> 
</head> 
<body onload="initialize()"> 
<div id="map_canvas"></div> 
</body> 
</html> 

다음은 KML 파일입니다. 내가 찾은 다른 KML 파일과는 모양이 다른 것 같습니다.

<?xml version="1.0" encoding="UTF-8"?> 
    <kml xmlns="http://earth.google.com/kml/2.0"> 
    <Document> 
    <name>Continents.kmz</name> 
    <Style id="khStyle646"> 
    <LineStyle id="khLineStyle649"> 
    <antialias>0</antialias> 
    </LineStyle> 
    <PolyStyle id="khPolyStyle648"> 
     <fill>0</fill> 
     <outline>0</outline> 
    </PolyStyle> 
    <IconStyle id="khIconStyle650"> 
     <Icon> 
     <href>root://icons/palette-3.png</href> 
     <x>160</x> 
     <y>128</y> 
     <w>32</w> 
     <h>32</h> 
     </Icon> 
    </IconStyle> 
    </Style> 
    <Style id="khStyle653"> 
    <LineStyle id="khLineStyle656"> 
     <antialias>0</antialias> 
    </LineStyle> 
    <PolyStyle id="khPolyStyle655"> 
     <fill>0</fill> 
     <outline>0</outline> 
    </PolyStyle> 
    <IconStyle id="khIconStyle657"> 
     <Icon> 
     <href>root://icons/palette-3.png</href> 
     <x>96</x> 
     <y>160</y> 
     <w>32</w> 
     <h>32</h> 
     </Icon> 
    </IconStyle> 
    </Style> 
    <Folder> 
    <description>All information from www.wikipedia.org</description> 
    <name>Continents</name> 
    <Placemark> 
     <LookAt> 
     <longitude>69.34975938772639</longitude> 
     <latitude>-85.51850370658478</latitude> 
     <range>4660494.527334587</range> 
     <tilt>1.489515791197339</tilt> 
     <heading>-94.23630609027376</heading> 
     </LookAt> 
     <styleUrl>#khStyle653</styleUrl> 
     <Point> 
     <coordinates>80.29122647597791,-85.36965069939549,0</coordinates> 
     </Point> 
    </Placemark> 
    <Placemark> 
     <name>North America</name> 
     <LookAt> 
     <longitude>-92.38030591736974</longitude> 
     <latitude>41.60040029662515</latitude> 
     <range>6572383.886462871</range> 
     <tilt>1.489515791197389</tilt> 
     <heading>5.091613582461503</heading> 
     </LookAt> 
     <styleUrl>#khStyle653</styleUrl> 
     <Point> 
     <coordinates>-98.11233984563178,45.32023029701742,0</coordinates> 
     </Point> 
    </Placemark> 
    <Placemark> 
      <name>South America</name> 
     <LookAt> 
     <longitude>-62.99013711154147</longitude> 
     <latitude>-21.48589474193573</latitude> 
     <range>7218561.25099345</range> 
     <tilt>1.489515791197348</tilt> 
     <heading>14.48258802805428</heading> 
     </LookAt> 
     <styleUrl>#khStyle653</styleUrl> 
     <Point> 
     <coordinates>-58.60850163074399,-15.26868557309036,0</coordinates> 
     </Point> 
    </Placemark> 
    <Placemark> 
     <description>The primary use of the term Oceania is to describe a continental region (like Europe or Africa) that lies between Asia and the Americas, with Australia as the major land mass. The name Oceania is used, rather than Australia, because unlike the other continental groupings, it is the ocean rather than the continent that links the nations together. Oceania is the smallest continental grouping in land area and the second smallest, after Antarctica, in population.</description> 
     <name>Australasia/Oceania</name> 
     <LookAt> 
     <longitude>149.9280610479762</longitude> 
     <latitude>-19.96203640214011</latitude> 
     <range>5948094.214726813</range> 
     <tilt>1.489515791197347</tilt> 
     <heading>-3.233441994279863</heading> 
     </LookAt> 
     <styleUrl>#khStyle653</styleUrl> 
     <Point> 
     <coordinates>153.0281098590235,-19.81023956617555,0</coordinates> 
     </Point> 
    </Placemark> 
    <Placemark> 
     <name>Europe</name> 
     <LookAt> 
     <longitude>13.36662252078061</longitude> 
     <latitude>47.49923408453745</latitude> 
     <range>2926553.150350343</range> 
     <tilt>1.489515791197361</tilt> 
     <heading>5.315432286214211</heading> 
     </LookAt> 
     <styleUrl>#khStyle653</styleUrl> 
     <Point> 
     <coordinates>7.703642655915047,48.19165017141015,0</coordinates> 
     </Point> 
    </Placemark> 
    <Placemark> 
     <name>Asia</name> 
     <LookAt> 
     <longitude>88.44296071080763</longitude> 
     <latitude>29.02076366275569</latitude> 
     <range>5948094.214726811</range> 
     <tilt>1.489515791197341</tilt> 
     <heading>4.339173834203948</heading> 
     </LookAt> 
     <styleUrl>#khStyle653</styleUrl> 
     <Point> 
     <coordinates>88.87769612972068,35.90237786706015,0</coordinates> 
     </Point> 
    </Placemark> 
    <Placemark> 
     <name>Africa</name> 
     <LookAt> 
     <longitude>20.16987332895207</longitude> 
     <latitude>1.368208952904757</latitude> 
     <range>8150113.588222869</range> 
     <tilt>1.489515791197357</tilt> 
     <heading>-4.536422889821256</heading> 
     </LookAt> 
     <styleUrl>#khStyle646</styleUrl> 
     <Style> 
     <IconStyle> 
      <Icon> 
      <href>root://icons/palette-3.png</href> 
      <x>96</x> 
      <y>160</y> 
      <w>32</w> 
      <h>32</h> 
      </Icon> 
     </IconStyle> 
     </Style> 
     <Point> 
     <coordinates>21.06451559663505,6.103658771972451,0</coordinates> 
     </Point> 
    </Placemark> 
    </Folder> 
</Document> 
</kml> 

파일이 Google 어스와 관련이 있다고 생각합니다. Google지도 KML로 변환 할 수 있습니까? 왜 작동하지 않는지 제발 알려주시겠습니까?

감사합니다,

요시

답변

2

당신이 KML 파일있어 꽤 멀다 구식이다. 네임 스페이스를 살펴보면 KML 2.0 파일이며 실제로는 성문화 된 스펙이 아닙니다. KML 2.1이 가장 빠르며 KML 2.2가 최신 버전입니다. 따라서 antialias와 x, y 등과 같이 지원되지 않는 요소가 많이 있습니다. 일부 요소가 잘못되어 있습니다. 스키마에 대해 유효성 검사를 시도해 볼 수 있습니다. http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd

그러면 어떤 요소가 지원되지 않고 어떤 요소가 고장 났는지 알 수 있습니다. 무료 평가판 인 Oxygen과 같은 유효성 검사기를 사용할 수 있습니다.

또한 Google지도의 KML 렌더러 인 KmlLayer를 사용하는 대신 공개 소스 프로젝트 인 geoxml3을 사용하고 있습니다. 그래서 yo는 geoxml3 사람들에게 도움을 요청할 수 있습니다.

1

어쩌면이 링크는 KML의 요소 중 일부는 지원되지 않습니다 당신을 도울 수 : 그래서

https://developers.google.com/kml/documentation/kmlelementsinmaps

+0

이 도구를 사용하여이 파일을 KML로 변경할 수 있습니까? – user1365697

+0

이 파일은 Google 어스와 관련이 있습니다. Google지도 API에도이 파일을 사용할 수 있습니까? http://serc.carleton.edu/sp/library/google_earth/kml_examples_from_google.html – user1365697

+0

도구 : http://download.cnet.com/Google-Earth-KMZ-or-KML-to-GPS-Converter/3000- 12940_4-10619131.html – lfergon