2010-02-23 2 views
5

아주 간단한 질문입니다.KML + Google 어스 : 다각형 또는 그라운드 오버레이를 클릭 할 수있게 만드시겠습니까?

KML에서 정의 된 일부 다각형 및 GroundOverlays가 있습니다. 클릭 할 수 있어야한다고 지정하는 방법이 있습니까? (Google 어스에서 최소한) 클릭하면 정보 풍선 등이 나타납니다.

마찬가지로 polygons/GroundOverlays에 마우스 오버 동작을 지정할 수 있습니까? 예 : 마우스를 가져 가면 아이콘이나 색상이 바뀝니 까?

답변

10

예. 장소 표시에 이름과 설명을 입력하면 Google 어스에서 클릭 가능한 개체가되며 정보 창이 표시되어 둘 다 표시됩니다. 스타일 오버랩을 사용하여 마우스 오버/마우스 오버 동작을 만들 수 있습니다. 여기에 두 가지 예가 나와 있습니다.

<?xml version="1.0" encoding="UTF-8"?> 
<kml xmlns="http://www.opengis.net/kml/2.2"> 
<Document> 
<name>Highlighted Icon</name> 
<description>Place your mouse over the icon to see it display the new 
     icon</description> 
<StyleMap id="exampleStyleMap"> 
    <Pair> 
    <key>normal</key> 
    <!-- you could also use a <styleUrl> here instead of inlining --> 
    <Style> 
     <PolyStyle> 
     <color>7dff0000</color> 
     </PolyStyle> 
    </Style> 
    </Pair> 
    <Pair> 
    <key>highlight</key> 
    <!-- you could also use a <styleUrl> here instead of inlining --> 
    <Style> 
     <PolyStyle> 
     <color>7dffffff</color> 
     </PolyStyle> 
    </Style> 
    </Pair> 
</StyleMap> 

<!-- and now, a Placemark that uses the StyleMap --> 
<Placemark> 
    <name>Roll over this polygon</name> 
    <description>this will show up when clicked</description> 
    <visibility>1</visibility> 
    <styleUrl>#exampleStyleMap</styleUrl> 
    <Polygon> 
    <tessellate>1</tessellate> 
    <altitudeMode>absolute</altitudeMode> 
    <outerBoundaryIs> 
     <LinearRing> 
     <coordinates> 
      -112.3372510731295,36.14888505105317,1784 
      -112.3356128688403,36.14781540589019,1784 
      -112.3368169371048,36.14658677734382,1784 
      -112.3384408457543,36.14762778914076,1784 
      -112.3372510731295,36.14888505105317,1784 
     </coordinates> 
     </LinearRing> 
    </outerBoundaryIs> 
    </Polygon> 
</Placemark> 
</Document> 
</kml> 
+0

감사합니다. 매우 감사. – DanM

+0

한 가지 질문 : 각 장소 표시에 대해 개별적으로 두 부분으로 된 스타일을 사용할 수 있습니까? 예를 들어 100 개의 JPEG 이미지 라이브러리가 있고지도 위에 100 개의 단색 폴리곤이 배치되어 있습니다. 그 중 하나 위에 마우스를 올리면 100 개의 이미지 중 하나가 그 위치에 나타납니다. – DanM

관련 문제