HELP NEEDED

1,754 views
Skip to first unread message

GREASE

unread,
Aug 20, 2008, 3:32:47 PM8/20/08
to KML Developer Support - Advanced Support for KML
hi ,

with refrence to the tutorial for creating kml file using php mysql i
need to know how to create placemarks with diffrent colours ?

what modifications to be done in the code so that it shall display
placemark icons of red / green / blue / yellow / orange colours

how to use custom placemark icons and what are the changes to be made
in the code

thanx

Roman N

unread,
Aug 21, 2008, 6:56:48 PM8/21/08
to KML Developer Support - Advanced Support for KML
Hi,

You have two options here:

1) You can use different placemark icons, one for each color:

<Placemark>
<IconStyle>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/red-
pushpin.png</href>
</Icon>
</IconStyle>
...
</Placemark>

That will make a red pushpin placemark. Some others are:
http://maps.google.com/mapfiles/kml/pushpin/grn-pushpin.png
http://maps.google.com/mapfiles/kml/pushpin/blue-pushpin.png

You can use your own icons, or use one from our set. You can browse
our set in Google Earth: create a placemark, right click it, press
Properties (or Get Info) and click the icon to the right of the
placemark name.

2) Or, you can use a white icon, such as http://maps.google.com/mapfiles/kml/pushpin/wht-pushpin.png
and then apply a color over it:

<Placemark>
<IconStyle>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/wht-
pushpin.png</href>
</Icon>
<colorMode>normal</colorMode>
<color>ff0000ff</color>
</IconStyle>
...
</Placemark>

"ff0000ff" will make the icon red, as <color> is of the form
"aabbggrr" (alpha, blue, green, red).

For more info on either of these, check the KML reference for
IconStyle at http://code.google.com/apis/kml/documentation/kmlreference.html#iconstyle

- Roman
Message has been deleted

Marcin Pawlowski

unread,
Aug 27, 2008, 3:01:27 PM8/27/08
to KML Developer Support - Advanced Support for KML
Next time for the sake of our eyes post a link to your kml rather than
straight code if it's so long, thanks :)

In your first <Style> deceleration you are missing the <href> tag

<Style id="restaurantStyle">
<IconStyle id="restuarantIcon">
<Icon>
<----missing href tag goes here----> http://maps.google.com/mapfiles/kml/pushpin/grn-pushpin.png</href>
</Icon>
</IconStyle>
</Style>

Then when you reference the styles, dont use #Style, but use the names
you provided in the id's.

<styleUrl>#restaurantStyle</styleUrl>





On Aug 27, 8:52 am, GREASE wrote:
> this is my code can u point out where i am going wrong?
>
> <?xml version="1.0" encoding="UTF-8"?>
> <kml xmlns="http://earth.google.com/kml/2.1">
>  <Document>
>  <Style id="restaurantStyle">
>  <IconStyle id="restuarantIcon">
>  <Icon>
>  http://maps.google.com/mapfiles/kml/pushpin/grn-pushpin.png</href>
>  </Icon>
>  </IconStyle>
>  </Style>
>  <Style id="barStyle">
>  <IconStyle id="barIcon">
>  <Icon>
>  <href>http://maps.google.com/mapfiles/kml/pal2/icon27.png</href>
>  </Icon>
>  </IconStyle>
>  </Style>
>  <Placemark id="placemark1">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8335,18.9345</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark2">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8334,18.9346</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark3">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8335,18.9346</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark4">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8335,18.9346</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark5">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8325,18.9347</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark6">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8325,18.9345</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark7">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8326,18.9345</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark8">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8326,18.9344</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark9">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8324,18.9343</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark10">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8324,18.9341</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark11">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8323,18.934</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark12">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8322,18.9339</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark13">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8322,18.9338</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark14">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8321,18.9336</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark15">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.832,18.9336</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark16">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.832,18.9334</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark17">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8319,18.9332</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark18">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.832,18.9331</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark19">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8319,18.9331</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark20">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8318,18.933</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark21">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8317,18.933</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark22">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8316,18.9329</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark23">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8314,18.9324</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark24">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8314,18.9323</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark25">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8314,18.9322</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark26">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8314,18.932</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark27">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8313,18.9318</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark28">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8314,18.9317</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark29">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8314,18.9315</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark30">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8314,18.9314</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark31">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8314,18.9313</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark32">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8314,18.9311</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark33">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8313,18.9309</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark34">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8313,18.9308</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark35">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8311,18.9305</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark36">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8311,18.9305</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark37">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8312,18.9304</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark38">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8313,18.9302</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark39">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8313,18.93</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark40">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8312,18.9299</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark41">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8312,18.9298</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark42">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8312,18.9296</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark43">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8312,18.9295</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark44">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8312,18.9291</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark45">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8312,18.929</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark46">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8313,18.9288</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark47">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8313,18.9288</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark48">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8312,18.9286</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark49">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8313,18.9283</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark50">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>
>  <coordinates>72.8314,18.9283</coordinates>
>  </Point>
>  </Placemark>
>  <Placemark id="placemark51">
>  <name></name>
>  <description></description>
>  <styleUrl>#Style</styleUrl>
>  <Point>...
>
> read more »

jpwade_bsu

unread,
Aug 27, 2008, 9:40:55 PM8/27/08
to KML Developer Support - Advanced Support for KML
Hello Grease,

Try http://www.czmartin.com/jpw/asp_arcmap/index.asp for some tips

jpwade
www.czmartin.com/jpw


On Aug 20, 12:32 pm, GREASE wrote:

Vee Why

unread,
Oct 8, 2008, 6:28:27 PM10/8/08
to KML Developer Support - Advanced Support for KML
Roman,

I tried your code with this, but the pushpins remained default yellow.
What am I doing wrong, and... If say I have a list of 20 places, can I
just code for the whole folder to be red, instead of coding each point
individually?

my present code:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Document>
<name>points 7 to 7</name>
<Folder>
<Placemark><name>Somwhere House (section 7) </name><address>Main
Street, XYZ</address><description> LOL:<br> LOR:</br><br> LOL:</
br><br> LOR:</br></description>
<IconStyle>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/wht-
pushpin.png</href>
</Icon>
<colorMode>normal</colorMode>
<color>ff0000ff</color>
</IconStyle>
</Placemark>
</Folder>
</Document>
</kml>


On Aug 21, 11:56 pm, Roman N wrote:
> Hi,
>
> You have two options here:
>
> 1) You can use different placemark icons, one for each color:
>
> <Placemark>
>   <IconStyle>
>     <Icon>
>       <href>http://maps.google.com/mapfiles/kml/pushpin/red-
> pushpin.png</href>
>     </Icon>
>   </IconStyle>
>   ...
> </Placemark>
>
> That will make a red pushpin placemark. Some others are:http://maps.google.com/mapfiles/kml/pushpin/grn-pushpin.pnghttp://maps.google.com/mapfiles/kml/pushpin/blue-pushpin.png
>
> You can use your own icons, or use one from our set. You can browse
> our set in Google Earth: create a placemark, right click it, press
> Properties (or Get Info) and click the icon to the right of the
> placemark name.
>
> 2) Or, you can use a white icon, such ashttp://maps.google.com/mapfiles/kml/pushpin/wht-pushpin.png
> and then apply a color over it:
>
> <Placemark>
>   <IconStyle>
>     <Icon>
>       <href>http://maps.google.com/mapfiles/kml/pushpin/wht-
> pushpin.png</href>
>     </Icon>
>     <colorMode>normal</colorMode>
>     <color>ff0000ff</color>
>   </IconStyle>
>   ...
> </Placemark>
>
> "ff0000ff" will make the icon red, as <color> is of the form
> "aabbggrr" (alpha, blue, green, red).
>
> For more info on either of these, check the KML reference for
> IconStyle athttp://code.google.com/apis/kml/documentation/kmlreference.html#icons...
>
> - Roman
>
> On Aug 20, 12:32 pm, GREASE wrote:
>
>
>
> > hi ,
>
> > with refrence to the tutorial for creating kml file using php mysql i
> > need to know how to create placemarks with diffrent colours ?
>
> > what modifications to be done in the code so that it shall display
> > placemark icons of red / green / blue / yellow / orange colours
>
> > how to use custom placemark icons and what are the changes to be made
> > in the code
>
> > thanx- Hide quoted text -
>
> - Show quoted text -

Roman N

unread,
Oct 8, 2008, 7:49:32 PM10/8/08
to KML Developer Support - Advanced Support for KML
Hi Vee Why,

You forgot to wrap <IconStyle> inside a <Style> :)

...
<Style>
<IconStyle>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/wht-
pushpin.png</href>
</Icon>
<colorMode>normal</colorMode>
<color>ff0000ff</color>
</IconStyle>
</Style>
...

Also, you don't need to do <br> and </br>... you can just wrap your
description content inside a <![CDATA[ ]]>

- Roman
> > That will make a red pushpin placemark. Some others are:http://maps.google.com/mapfiles/kml/pushpin/grn-pushpin.pnghttp://map...

Vee Why

unread,
Oct 9, 2008, 6:10:41 AM10/9/08
to KML Developer Support - Advanced Support for KML
Hi Roman,

That worked nicely, but... I have a large number of locations, output
from a database, each group will go in its own folder. But because of
exporting/parsing issues by putting the whole <style> ... </style>
code in between <Placemark> ... </Placemark>, it throws the xml out
resulting in lots of these type characters □□□□????□□□????□□□□□□□ . So
the question is can the whole <Style> ... <Style> section go before
<Placemark> .... </Placemark>, bearing in mind I want to color code
the whole folder, not individual points; in other words, is there a
way of having the style color icon set for any ALL items in the folder
before the GE parser gets to the actual Placemark stuff? that way I
can get around my export long strings issue.
> > > - Show quoted text -- Hide quoted text -

Roman N

unread,
Oct 13, 2008, 2:00:34 PM10/13/08
to KML Developer Support - Advanced Support for KML
Hi Vee Why,

Sure, you can use shared styles... see the tutorial page at:

http://code.google.com/apis/kml/documentation/kml_tut.html#geometrystyles)

Here's a quick sample:

<Folder>
...
<Style id="red-pushpins">
<IconStyle>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pushpin/wht-
pushpin.png</href>
</Icon>
<colorMode>normal</colorMode>
<color>ff0000ff</color>
</IconStyle>
</Style>
...
<Placemark>
...
<styleUrl>#red-pushpins</styleUrl>
...
</Placemark>
...
</Folder>

Using <styleUrl> you can refer to a shared style from within any
placemark.

- Roman
Reply all
Reply to author
Forward
0 new messages