Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apply specific Styles to lines in a MultiGeometry in KML

Tags:

kml

Hello I have a multigeometry How has a Style like a rollover when you pass the mouse appair the lines, My question is the diferents linestring in the multigeometry have differents colors that possible?.

In the next example I have the placemark Durham Tees Valley when you select have a style but I would like have the two lines with differents colors.

Thanks

    <?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>
like image 728
Jonathan Raul Tapia Lopez Avatar asked Nov 28 '11 10:11

Jonathan Raul Tapia Lopez


2 Answers

No, see the KML FAQ, they address your question:

Can I assign different colors/styles to different geometries in a MultiGeometry element?

The MultiGeometry element groups geometries together in the same Placemark element. This allows the geometries to share the same styling and to appear as one item in a list such as the My Places pane in Google Earth.

Styles are set at the Placemark level, either using a styleUrl element or a Style element. Therefore, individual geometries in that Placemark cannot have different styles.

Also see the workaround which I found useful:

A frequently used workaround is to create a separate Placemark for each geometry, allowing each one to have a different style. To prevent a proliferation of items in a list, place them in a Folder that has a ListStyle with a listItemType with checkHideChildren. In Google Earth, for instance, this places all the Placemarks in the same folder element in My Places, and prevents the user from opening it up to display a large number of elements.

like image 186
Konrad Reiche Avatar answered Oct 11 '22 13:10

Konrad Reiche


No, it's not possible. Multigeometry is a child of Placemark, which has the styleUrl element. You'd do better to break them up into different Placemark elements and group them on a Folder level.

like image 36
Mano Marks Avatar answered Oct 11 '22 14:10

Mano Marks