应用特定的样式,以线在MultiGeometry在KML

问题描述:

你好,我有一个multigeometry是如何像一个侧翻样式当你通过鼠标appair行,我的问题是在multigeometry有型动物的色彩,可能LINESTRING的diferents?应用特定的样式,以线在MultiGeometry在KML

在下面的例子中我有标达勒姆蒂斯瓦利当您选择有一番风情,但我想有两行型动物的颜色。

感谢

<?xml version="1.0" encoding="UTF-8"?> 
<kml xmlns="http://earth.google.com/kml/2.2"> 
<Document> 
<name>UK &amp; Ireland, Flight Maps</name> 
<open>1</open> 
     <LookAt> 
      <longitude>-3.478829007934099</longitude> 
      <latitude>52.50255557278696</latitude> 
      <altitude>0</altitude> 
      <range>730703.2034581316</range> 
      <tilt>53.03089122623036</tilt> 
      <heading>30.72599120906411</heading> 
     </LookAt> 


    <Style id="test"> 
    <LineStyle> 
     <color>ff235523</color> 
     <width>0.5</width> 
    </LineStyle> 
    </Style> 

<Style id="doc"><ListStyle><ItemIcon><state>open closed</state><href>http://maps.google.com/mapfiles/kml/shapes/airports.png</href></ItemIcon></ListStyle></Style> 
<Style id="airportfolder"><ListStyle><ItemIcon><state>open closed</state><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle_highlight.png</href></ItemIcon></ListStyle></Style> 
<Style id="info"><ListStyle><listItemType>checkHideChildren</listItemType><ItemIcon><state>open closed</state><href>http://www.barnabu.co.uk/files/icons/info.png</href></ItemIcon></ListStyle></Style> 
<Style id="sh_spider"><IconStyle><scale>1.2</scale><Icon><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle_highlight.png</href></Icon></IconStyle><LabelStyle><color>ff001111</color><scale>1.4</scale></LabelStyle><LineStyle><width>0.5</width><color>ffff111f</color></LineStyle></Style> 
<Style id="sn_spider"><IconStyle><scale>0.7</scale><Icon><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle_highlight.png</href></Icon></IconStyle><LabelStyle><color>ffb5b5b5</color><scale>0.9</scale></LabelStyle><LineStyle><color>00ff11ff</color></LineStyle></Style> 
<StyleMap id="spider"><Pair><key>normal</key><styleUrl>#sn_spider</styleUrl></Pair><Pair><key>highlight</key><styleUrl>#sh_spider</styleUrl></Pair></StyleMap> 


<Style id="2_sh_spider"><IconStyle><scale>1.2</scale><Icon><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle_highlight.png</href></Icon></IconStyle><LabelStyle><color>ff110011</color><scale>1.4</scale></LabelStyle><LineStyle><width>0.5</width><color>ff11111f</color></LineStyle></Style> 
<Style id="2_sn_spider"><IconStyle><scale>0.7</scale><Icon><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle_highlight.png</href></Icon></IconStyle><LabelStyle><color>ff11ffb5</color><scale>0.9</scale></LabelStyle><LineStyle><color>001111ff</color></LineStyle></Style> 
<StyleMap id="2_spider"><Pair><key>normal</key><styleUrl>#2_sn_spider</styleUrl></Pair><Pair><key>highlight</key><styleUrl>#2_sh_spider</styleUrl></Pair></StyleMap> 


<styleUrl>#doc</styleUrl> 
<Folder><name>Airports</name> 
<styleUrl>#airportfolder</styleUrl> 


<Placemark><name>Durham Tees Valley</name><description></description> 
<Snippet maxLines="0"></Snippet><styleUrl>#2_spider</styleUrl><MultiGeometry><LineString><altitudeMode>relativeToGround</altitudeMode><coordinates>-1.426979,54.5105876,0 -1.37505058232182,54.3588196840161,8130.76624025246 -1.32350445540046,54.2070296447423,15640.4403479026 -1.27233575193875,54.0552177670135,22453.9881416349 -1.22153968418068,53.90338433094,28503.3309041539 -1.17111154230159,53.7515296120054,33728.0256022233 -1.12104669283672,53.5996538811612,38075.8688134745 -1.07134057714712,53.4477574049198,41503.4183257466 -1.02198870992187,53.2958404454444,43976.4271973102 -0.972986677715595,53.1439032606379,45470.1859409886 -0.924330137520422,52.9919461042286,45969.769413186 -0.876014815371306,52.8399692258547,45470.1859409886 -0.828036504983954,52.6879728711457,43976.4271973102 -0.780391066424406,52.5359572818033,41503.4183257466 -0.733074424809449,52.3839226956791,38075.8688134745 -0.686082569037039,52.2318693468513,33728.0256022233 -0.639411550545936,52.0797974656991,28503.3309041538 -0.593057482103787,51.9277072789755,22453.9881416349 -0.547016536622892,51.7755990098789,15640.4403479026 -0.501284946002942,51.623472878122,8130.76624025247 -0.455859000000019,51.4713291000001,0 </coordinates></LineString> 
<LineString><altitudeMode>relativeToGround</altitudeMode><coordinates>-1.426979,54.5105876,0 -1.37505058232182,54.3588196840161,8130.76624025246 -1.32350445540046,54.2070296447423,15640.4403479026 -1.27233575193875,54.0552177670135,22453.9881416349 -1.22153968418068,53.90338433094,28503.3309041539 -1.17111154230159,53.7515296120054,33728.0256022233 -1.12104669283672,53.5996538811612,38075.8688134745 -1.07134057714712,53.4477574049198,41503.4183257466 -1.02198870992187,53.2958404454444,43976.4271973102 -0.972986677715595,53.1439032606379,45470.1859409886 -0.924330137520422,52.9919461042286,45969.769413186 -0.876014815371306,52.8399692258547,45470.1859409886 -0.828036504983954,52.6879728711457,43976.4271973102 -0.780391066424406,52.5359572818033,41503.4183257466 -0.733074424809449,52.3839226956791,38075.8688134745 -0.686082569037039,52.2318693468513,33728.0256022233 -0.639411550545936,52.0797974656991,28503.3309041538 -0.593057482103787,51.9277072789755,22453.9881416349 -0.547016536622892,51.7755990098789,15640.4403479026 -0.501284946002942,51.623472878122,8130.76624025247 -0.455859000000019,51.4713291000001,0 </coordinates></LineString> 
<LineString><altitudeMode>relativeToGround</altitudeMode><coordinates>-1.426979,54.5105876,0 -1.46306991162193,54.6452657167915,8130.76624025246 -1.4994007562172,54.7799330335197,15640.4403479026 -1.5359743201564,54.9145894238809,22453.9881416349 -1.57279343190481,55.0492347596452,28503.3309041539 -1.6098609628193,55.1838689106202,33728.0256022233 -1.64717982796325,55.3184917446126,38075.8688134745 -1.6847529869399,55.4531031273904,41503.4183257466 -1.72258344474472,55.5877029226427,43976.4271973102 -1.76067425263717,55.7222909919396,45470.1859409886 -1.79902850903249,55.8568671946911,45969.769413186 -1.83764936041401,55.9914313881044,45470.1859409886 -1.87654000226647,56.1259834271408,43976.4271973102 -1.91570368003095,56.2605231644716,41503.4183257466 -1.95514369008209,56.3950504504321,38075.8688134745 -1.99486338072804,56.5295651329761,33728.0256022233 -2.03486615323379,56.6640670576277,28503.3309041538 -2.0751554628687,56.7985560674327,22453.9881416349 -2.11573481997855,56.933032002909,15640.4403479026 -2.15660779108317,57.0674947019956,8130.76624025247 -2.19777799999999,57.201944,0 </coordinates></LineString> 

<Point><coordinates>-1.426979,54.5105876,0</coordinates></Point></MultiGeometry></Placemark> 

</Folder> 

</Document> 
</kml> 

不,这是不可能的。 Multigeometry是Placemark的子项,它具有styleUrl元素。你最好将它们分解成不同的地标元素,并将它们分组在文件夹级别。

+0

文件夹是一个合理的解决办法,直到你想使用StyleMap设定,让鼠标突出不同的造型。如果您设置文件夹的样式,那么所有的孩子都会得到相同的样式,但是如果您对孩子进行了样式设计,则一次只能有一个可以获得高光。除非我错过了一些东西。 – yoyo

没有,看到KML常见问题,他们解决您的question

我可以分配不同的颜色/样式不同的几何形状在 MultiGeometry元素

的MultiGeometry元件组的几何形状一起 在同一标元素。这允许 几何图形共享相同的样式,并在列表中显示为一个项目,例如Google地球中的我的位置窗格 。

样式设定在标水平,或者使用一个styleUrl元件 或风格元素。因此,该地标 中的单个几何图形不能具有不同的样式。

也看到,我发现有用的解决方法:

经常使用的方法是: 创建一个单独的标每个几何,允许每个拥有不同的风格。为了防止 列表中的项目的激增,将它们放置在一个文件夹具有 ListStylelistItemTypecheckHideChildren。在谷歌地球, 例如,这个地方在我的位置在同一文件夹 元素所有地标,并阻止用户打开它以 显示大量的元素。