Google Earth encoding

6,053 views
Skip to first unread message

Gonard

unread,
Apr 11, 2008, 10:13:02 AM4/11/08
to KML Developer Support - Getting Started with KML
Hi
I have a KML file with a networklink to a file on my server. This file
echos the information that are necessary to display all the markers
with the information for the infowinodws in GE. The coordinates and
the information for the infowindows are saved in a XML file that is
saved in UTF-8.
Nearly everything works fine in GE. It displays the markers at the
right possition and also the infowindows (with text in it) belongs to
the right markers. But when i have a "EURO" character , GE does not
display it as "EURO" but it displays the character as "â?¬".
I thought when i define the encoding at the beginning of the KML file
that GE displays it right and makes an "EURO" character instead of "â?
¬"!?
Here is the KML-file with the networklink im using:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<NetworkLink>
<name>Marker</name>
<open>1</open>
<Link>
<href>Link to the Script</href>
<refreshMode>onChange</refreshMode>
<httpQuery>xmlname=markers</httpQuery>
</Link>
</NetworkLink>
</kml>

When i use the same XML file in Google Maps API to display the markes
and infowindows, all characters are displayed right. Even the "EURO"
character.

Can anybody give me a hint what iva done wrong?

greetings Gonard

barryhunter [KML Guru]

unread,
Apr 11, 2008, 5:07:30 PM4/11/08
to KML Developer Support - Getting Started with KML
The file you showed is the network link file, but you need to make
sure you encode it correctly in the content file itself..

If you provide a link to the real file, the others can actully take a
look real file.

Gonard

unread,
Apr 12, 2008, 6:38:25 AM4/12/08
to KML Developer Support - Getting Started with KML
Hi
Here is the KML file with the networklink, so u can open it with GE.
http://www.easttraxx.de/marker_network/networklink_marker.kml

Here is the code from the file on my server:
<?php

echo <<<LANG
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Document>
<StyleMap id="test">
<Pair>
<key>normal</key>
<styleUrl>#parcelNormal</styleUrl>
</Pair>
<Pair>
<key>highlight</key>
<styleUrl>#parcelHighlight</styleUrl>
</Pair>
</StyleMap>
<Style id="parcelNormal">
<IconStyle>
<scale>0</scale>
<color>ffffffff</color>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal4/icon56.png</href>
<x>32</x>
<y>128</y>
<w>32</w>
<h>32</h>
</Icon>
</IconStyle>
<LabelStyle>
<color>FFFFFFFF</color>
</LabelStyle>
</Style>
<Style id="parcelHighlight">
<IconStyle>
<scale>0</scale>
<color>ff0000ff</color>
<Icon>
<href>http://maps.google.com/mapfiles/kml/pal4/icon56.png</href>
<x>32</x>
<y>128</y>
<w>32</w>
<h>32</h>
</Icon>
</IconStyle>
<LabelStyle>
<color>FF000000</color>
</LabelStyle>
<BalloonStyle>
<!-- a background color for the balloon -->
<bgColor>00ffffff</bgColor>
<!-- styling of the balloon text -->
<text><![CDATA[$[description]]]></text>
</BalloonStyle>
</Style>
LANG;

$xmlname=$_GET[xmlname];

$xml2=simplexml_load_file($xmlname.'.xml');

echo"
<Folder>
<name>Marker</name>
<open>0</open>";

$ii=0;
foreach($xml2->flurstueck as $fs)
{
foreach($xml2->flurstueck[$ii]->attributes() as $a => $b)
{
switch ($a)
{
case id: $name_m=$b;break;
case flaeche: $flaeche_m=$b;break;
case preis: $preis_m=$b;
case strasse: $strasse_m=$b;
case status: $status_m=$b;break;
case marker: $marker_m=$b;break;
}
}
if ($marker_m!=null)
{
echo "<Placemark>";
$desc_m="<table width=200 cellpadding=0 cellspacing=0 style=font-size:
10pt;>
<tr><td>Name: <font color=#cc0000><b>".$name_m."</b></td></tr>
<tr><td>Strasse: <font color=#cc0000><b>".$strasse_m."</b></td></tr>
<tr><td bgcolor=#8bb801><font color=#ffffff><b>Fläche: ".
$flaeche_m."qm</b></td></tr>
<tr><td bgcolor=#8bb801><font color=#ffffff><b>Preis: ".$preis_m."</
b></td></tr></table>";

echo "<name>".$name_m."</name>";
if ($status_m!="3")
{
echo "<description><![CDATA[".$desc_m."]]></description>";
}

echo "<styleUrl>#test</styleUrl>";

echo "<Point>
<extrude>0</extrude>
<altitudeMode>clampedToGround</altitudeMode>
<coordinates>".$marker_m."
</coordinates>
</Point>
";
echo "</Placemark>";
}
$ii++;
}
echo "
</Folder>
</Document>
</kml>";
?>

and here the XML i used to get the information for the markers:
http://www.easttraxx.de/marker_network/marker_daten.xml

barryhunter [KML Guru]

unread,
Apr 12, 2008, 10:24:18 AM4/12/08
to KML Developer Support - Getting Started with KML
Ah! Feedvalidator points to a few errors

http://feedvalidator.org/check.cgi?url=http%3A%2F%2Feasttraxx.de%2Fmarker_network%2Fmarker.php%3Fxmlname%3Dmarker_daten

See for the MIME types required.
http://code.google.com/apis/kml/documentation/kml_tut.html#kml_server

On Apr 12, 11:38 am, Gonard wrote:
> Hi
> Here is the KML file with the networklink, so u can open it with GE.http://www.easttraxx.de/marker_network/networklink_marker.kml

Gonard

unread,
Apr 12, 2008, 12:26:05 PM4/12/08
to KML Developer Support - Getting Started with KML
hey thanks...i just added the line "header('Content-type: text/html;
charset=utf-8');" at the beginning of the file. Now GE displays it
right.

thanks a lot.

greetings Gonard

On 12 Apr., 16:24, barryhunter [KML Guru] wrote:
> Ah! Feedvalidator points to a few errors
>
> http://feedvalidator.org/check.cgi?url=http%3A%2F%2Feasttraxx.de%2Fma...

Gonard

unread,
Apr 14, 2008, 3:36:35 AM4/14/08
to KML Developer Support - Getting Started with KML
hi
i think the line "header('Content-Type: application/vnd.google-
earth.kml+xml');" is the better way.
---------------------------------------------
I have one more question:
How can i do a "httpQuery" with more than 1 parameter? i need 2
information in the httpQuery. one is a name of a XML file and the
other information is a weblink.
I tried --> <httpQuery>xmlname=name_of_the_xml;web=http://
name_of_the_weblink.php</httpQuery>
but this does not work :/

when i just have one parameter in the httpQuery everything works fine.

greetings Gonard

barryhunter [KML Guru]

unread,
Apr 14, 2008, 9:45:04 AM4/14/08
to KML Developer Support - Getting Started with KML

> I have one more question:
> How can i do a "httpQuery" with more than 1 parameter?

I think & is a more accepted parameter seperator, and possibly what GE
expects

<httpQuery>xmlname=name_of_the_xml&amp;web=http://
name_of_the_weblink.php</httpQuery>

Note that its XML so the & acully need to be encoded to &amp; at least
unless you are using CDATA (so also be very careful to encode the web
parameter)

ManoM

unread,
Apr 14, 2008, 10:15:28 AM4/14/08
to KML Developer Support - Getting Started with KML
Actually, the KML documentation recommends a ;.

I'm guessing the problem is that the URL needs to be escaped. Gonard,
can you start a new thread on this, and post your actual NetworkLink
code so we can try it out?

Mano

Gonard

unread,
Apr 14, 2008, 10:26:29 AM4/14/08
to KML Developer Support - Getting Started with KML
thanks..it works with &amp; !
Reply all
Reply to author
Forward
0 new messages