Folder icons - possible to change?

1,598 views
Skip to first unread message

Terry_Pinnell

unread,
Jun 9, 2006, 5:07:59 AM6/9/06
to KML Discussions
Following on from this thread in GE Plus Support I'm looking for ways to improve the structure of My Places here. As a specific, is it possible to somehow customise the icon used for folders please? Using just the same blank square seems very limiting.

--
Terry, West Sussex, UK

simon_a

unread,
Jun 9, 2006, 9:33:09 PM6/9/06
to KML Discussions
Hello Terry,

I use the same kind of system as tekgergedan; I keep all my placemarks and collections in folders in Windows itself.

This is partly because I have so many versions of projects and partly because I don't trust the client not to screw up 'My Places' (I opened GE a couple of months ago to find it completly empty for no apparent reason) and I don't trust myself not to delete something important (as there's no 'undo').

It is possible to change the icon for a folder, although I'm not sure this is possible to do using the client. If you save a folder as a KML file and open it with a text editor, you can place the <Icon> tag just after the <Folder> tag to specify an icon for the folder. If you then want to keep the folder in 'My places' with the new icon, you will have to open the KML file (into the 'Temporary Places' folder) and then move/cut and paste it into the 'My Places' folder.

Here's a sample from my Rail stations of Belgium collection:

<Folder>
<name>SNCB / NMBS (Belgium)</name>
<open>1</open>
<Icon>
<href>C:/kml/images/ge-sn-sm.png</href>
</Icon>
.
.
.


I hope this helps...

Simon.

Terry_Pinnell

unread,
Jun 10, 2006, 4:30:43 AM6/10/06
to KML Discussions
Thanks Simon, very helpful. I too have now switched to that method I have only my 'working' entries in My Places, all the rest in Windows folders.

Just tried your neat KLM icon-changing suggestion, and it worked fine, many thanks. This was my arbitrary example:



But now that I'm doing my organising in standard folders, it's an unnecessary luxury!

Could I raise a follow-up query please. With this new approach, when it comes to saving folders, paths, placemarks etc from GE back into your HD folder (whether new ones or edited replacements for existing entries), what dictates whether to use KML or KMZ please?

simon_a

unread,
Jun 10, 2006, 5:58:20 AM6/10/06
to KML Discussions
Hello Terry,

See this post: KML vs KMZ

Simon.

simon_a

unread,
Jun 10, 2006, 6:08:23 AM6/10/06
to KML Discussions
This is in response to a question posed by Terry_Pinnell, see this post: Re: Folder icons - possible to change?


Hello,

If you save a folder as KML, GE will save a simple text file* to your hard disk. If you save as KMZ, the data is compressed into a smaller file before being saved to disk in a similar way to zipping a file into a winzip or RAR archive; the compressed KMZ files will be considerably smaller than the KML files.

However, you probably wouldn't want to compress everything on your hard-drive. If you had a series of Office documents, you would probably keep them as normal on your hard-disk and only compress them if you wanted to send one by email.

With the size of today's hard-disks, the larger KML fies probably won't take up too much room. But, if you want to post to the forum, you'll be best with KMZ.

Saving as KML will allow you to make edits with a text editor (you can't do this if the file has been compressed).

Also worth noting: when you save a folder or placemark as KMZ, the image files of icons and overlays get saved into the same compressed file so, when you post it to the forum, everyone can see the same icon. This doesn't happen with KML as that is always just text.

If you save as KML and then change the file extension to XML, you can open the file in Microsoft Excel and get all the data into a spreadsheet (getting it back into KML is a whole different ball-game though!).

In summary, I tend to work with everything uncompressed until it comes to post it or share it in some way. I then open the KML file with the client and use the client to save it as KMZ before posting.

You'll want to organise your icons into folders as you do your KML files - but you've probably already done that...

Simon.


*If you create a KML file yourself and not with the GE client, the text must use UTF-8 encoding. For example, if using notepad, change the 'Encoding' pull-down option to UTF-8 before saving. If you don't, you risk incorrectly rendered characters or a file that the GE client refuses to open.

Terry_Pinnell

unread,
Jun 11, 2006, 12:21:59 PM6/11/06
to KML Discussions
Many thanks, Simon, much appreciate your help.

Valery35

unread,
Jun 12, 2006, 3:38:35 AM6/12/06
to KML Discussions
Thanks, Simon. Good manual.
I add also.

For update KMZ i use Total Commander. After place cursor to KMZ file press Ctrl+Page Down. You see structure and files of KML.
In Configuration>Options>Edit\View can setup Editor by F4.
I use Emeditor free www.emeditor.com
http://www.download.com/EmEditor-Free/3000-2352_4-10527010.html


How you use Excel?

simon_a

unread,
Jun 12, 2006, 4:46:08 AM6/12/06
to KML Discussions
Hello Vallery,

I use Excel to manage extra bits of information for description bubbles in each collection, such as codes and URLs for online CGI scripts and URLs for websites.

I then use VBA in Excel to generate the KML. As it runs through each placemark, it generates descriptions based on whether certain information exists. (For example, some of the SNCF stations link to station-details pages on the SNCF website, whilst some have no online reference and others still have live arrival links but no station details.)

Whilst Excel can produce XML output itself, by default it's full of extra Excel-added tags and it can't handle the application logic I need to produce the description bubbles (unless I put descriptions in the cells, and that would be a awful to manage).

It's a bit fiddly when I need to update a view in the GE Client - I then have to convert new output to Excel and match the new co-orinates with the supplimentary data - but I've a script to do this as well

I can't find a way of getting a VBA script to output data encoded as UTF-8, so I have to open the output in notepad.exe and re-save choosing UTF-8.

Not the most elegant solutiuon but it works well enough!

Cheers,

Simon.

rsgrillo

unread,
Jun 12, 2006, 6:25:28 AM6/12/06
to KML Discussions




Hi simon_a

Quote:

I can't find a way of getting a VBA script to output data encoded as UTF-8, so I have to open the output in notepad.exe and re-save choosing UTF-8.





I think I could use the a function like this one to encode UTF-8 in a VBA macro.



Private Declare Function WideCharToMultiByte Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long, ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, ByVal lpDefaultChar As Long, ByVal lpUsedDefaultChar As Long) As Long



Public Function UTF8_Encode(ByVal instring As String) As String

Dim sBuffer As String
Dim lLength As Long


If instring <> "" Then
lLength = WideCharToMultiByte(CP_UTF8, 0, StrPtr(instring), -1, 0, 0, 0, 0)
sBuffer = Space$(lLength)
lLength = WideCharToMultiByte(CP_UTF8, 0, StrPtr(instring), -1, StrPtr(sBuffer), Len(sBuffer), 0, 0)
sBuffer = StrConv(sBuffer, vbUnicode)
UTF8_Encode = Left$(sBuffer, lLength - 1)
Else
UTF8_Encode = ""
End If

End Function

tekgergedan

unread,
Jun 12, 2006, 6:31:58 AM6/12/06
to KML Discussions
rs, great info.

Should
Code:
If instring <> "" Then


be
Code:
If nz(instring,"") <> "" Then


instead?

rsgrillo

unread,
Jun 12, 2006, 6:48:05 AM6/12/06
to KML Discussions
Hi tek,

Well, I am not a VBA programmer.

That line only checks if instring is not empty. Any code to do this will be ok.

Also the variable CP_UTF8 shall be set to 65001 for the right codepage.

Regards

tekgergedan

unread,
Jun 12, 2006, 7:29:32 AM6/12/06
to KML Discussions
This code will help many.

You know, empty and null (null: not assigned any value yet except if dim'ed) is different. In VB, touching in null value variables creates error and stops the code. Therefore, when null-value probability exists, nz comes to help to simulate a value.

I dont know the string there would have any null value, though. Needs a tryout.
Need to say it is already defined by 'Public'.

rsgrillo

unread,
Jun 12, 2006, 8:16:14 AM6/12/06
to KML Discussions


In VB a string will not take a Null. If you try to assign a Null to a string (myString = Null) VB will generate an error. So, every string will have a value or will be empty (""). Only variant takes Null. I think that VBA will be similar. I don't know about VB.net.

Btw, I just discover that I already have posted in this subject here. I am sorry.

rsgrillo

unread,
Jun 12, 2006, 8:38:39 AM6/12/06
to KML Discussions
Just complementing..

If you want to show correctly UTF-8 in Excel probably you will have to convert it the other way:


Private Declare Function WideCharToMultiByte Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long, ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, ByVal lpDefaultChar As Long, ByVal lpUsedDefaultChar As Long) As Long

Public Function WideChar_Encode(ByVal instring As String) As String

Dim i, L As Long
Dim temp As String

L = Len(instring)
temp = String(L * 2, 0)

i = MultiByteToWideChar(CP_UTF8, 0, instring & Chr(0), -1, temp, L)
If i > 0 Then
WideChar_Encode = StrConv(Left(temp, (i - 1) * 2), vbFromUnicode)
i = InStr(WideChar_Encode, Chr(0))
If i Then WideChar_Encode = Left(WideChar_Encode, i - 1)
Else
WideChar_Encode = instring
End If

End Function

simon_a

unread,
Jun 12, 2006, 9:21:15 AM6/12/06
to KML Discussions
Hello guys,

Whoa! Thanks for all that.

Yes, I researched those functions a few weeks ago... I remember not getting very far with it and thought it was not possible in Office VBA.

However, with a bit more to go on now, I'll have another look. I'm no expert at this so I could very well have been wrong!

Cheers,

Simon.

rcd2951

unread,
Jul 9, 2006, 10:50:00 PM7/9/06
to KML Discussions
Hmmm.

I created my icon as 32 X 32 in 256 colors, edited the appropriate KML file, and added my icon as you;ve indicated, but it only shows on start up.
Once I open the folder the open folder icon appears, and when i close it the closed folder icon shows.

Thoughts? Ideas?

regards

JPearson
(rcd2951)

simon_a

unread,
Jul 10, 2006, 8:50:36 AM7/10/06
to KML Discussions
That's interesting. Are you using v3 of the client or Beta 4?

Terry_Pinnell

unread,
Jul 10, 2006, 9:50:29 AM7/10/06
to KML Discussions
I'm a bit puzzled by this thread. Here, it looks like this:



which has two quite separate and scrambled topics!

tekgergedan

unread,
Jul 10, 2006, 10:05:15 AM7/10/06
to KML Discussions
It is demanded to name the Subject suitable. What simon did was the correct way of posting.

Terry_Pinnell

unread,
Jul 10, 2006, 12:50:51 PM7/10/06
to KML Discussions
I don't follow. Why are two subjects mixed in the same thread?

barryhunter

unread,
Jul 10, 2006, 1:21:26 PM7/10/06
to KML Discussions
When replying to a post you can edit the 'Subject' which is useful to label small deviations from the original starting post, like Simon highlighing the KML/KMZ differences, not been truly about changing the folder icons. (just like this post isn't either!)

However you might like to try the 'Flat' mode of viewing - there is button top right - as that puts all the posts in one long list, and makes it much harder to miss an important reply

simon_a

unread,
Jul 10, 2006, 2:06:46 PM7/10/06
to KML Discussions
Hello Terry,

(I've gone and done it again!)

It was kind of beacuse you asked two seperate questions in the same thread.

It may have been less confusing to have seperated them by posting a new message rather than replying but, to be honest, it doesn't really matter that much...



It's always a good idea to change the subject line on a post (or an email for that matter) as it makes finding a message or text much easier later on...

Simon.

Terry_Pinnell

unread,
Jul 10, 2006, 3:53:27 PM7/10/06
to KML Discussions
OK, penny finally dropped I think I came back to the thread as a result of a search, and thought it had somehow got scrambled - like the folders in my Agent email/news reader sometimes do!

Barry: Did you see my query about KML Altitude Filler in this thread ?

rcd2951

unread,
Jul 10, 2006, 4:45:45 PM7/10/06
to KML Discussions
Beta 4...Never thought about that. Guess I'll have to report a bug...

JP

townie

unread,
Jul 21, 2006, 12:10:24 PM7/21/06
to KML Discussions
I'm also getting this behavior in Beta 4, but not in GE3...A custom icon will revert to the generic folder icon as soon as I click to open or close the folder. Oddly this behavior goes away if I delete the KML/KMZ and reopen during the same session of GE.

I've had no luck getting custom document-level or network link icons to be retained in either GE 3 or Beta 4. Anybody have suggestions for me? I've created all of these lovely icons and am very frustrated that I can't use them!

Thanks.

simon_a

unread,
Jul 22, 2006, 6:52:40 PM7/22/06
to KML Discussions
Hello,

Do you have this problem with KML and KMZ files? If only KMZ, I wonder if it's a problem with the way that the image is embedded in the compressed file(?).

Simon.

townie

unread,
Jul 24, 2006, 1:31:11 PM7/24/06
to KML Discussions
Quote:



Do you have this problem with KML and KMZ files? If only KMZ, I wonder if it's a problem with the way that the image is embedded in the compressed file(?).






Yes...both my KMZs with an embedded custom palette and KMLs that reference the custom palette at a web address have this problem of not retaining the custom folder icon.
Reply all
Reply to author
Forward
0 new messages