[MANUAL] Convert an existing KML/KMZ for offline use

Started by Ferretty, July 29, 2011, 20:47:11

0 Members and 2 Guests are viewing this topic.

Ferretty

Of course you can use any KML/KMZ offline. But if it links some images (icons and pictures), those won't be available offline if they haven't been cached before -- i.e. if you watched them all before. With version 1.9.4.2 of Locus, menion features to import KMZ files including images -- and those KMZ files I am refering to here. With a few steps, you can include the images with the KMZ, and import that file into Locus:

Remark first: In my example here I use the name "files" for the folder containing our images, as this is the name used by Google Earth KMZ export, and also used in Googles KMZ Tutorial. As it turned out later in this thread, it is a good idea to use a different name. Feel free to do so -- the folder name just must not end with .kmz, no other restrictions appear in either the tutorial or the reference (or I must have missed them).

  • Create an empty directory
  • If your original file is a KML, just copy it into this directory and name it doc.kml. If it is a KMZ, unpack it into this directory (it is a ZIP file).
  • If the directory does not contain a sub-directory named files, create it. Here we place all images
  • With your favorite editor, open the doc.kml and search for all the images. Download/copy them to the files directory
  • replace all links to those images you have in the files directory to point to files/<imagename>
  • ZIP the resulting directory and make sure the resulting file has the extension .kmz

That's all. But I will explain steps 4 and 5 a bit closer:

Step 4: Where to check for the images?
They are in two places: One is the icons in the styles, and the others are the <IMG> tags in the description. The former are enclosed with a <href> tag.

Step 5: Renaming examples
Icon-Example: <href>http://maps.google.com/mapfiles/kml/shapes/hiker.png</href>
This should read <href>files/hiker.png</href> afterwards.

Image-example: <img src="http://www.example.com/images/foo.jpg">
As currently there is no cleanup mechanism in Locus, it is a good idea to include the KMZ name in all those image names. So if your resulting KMZ will be greece.kmz, you should have stored this image as greece_foo.jpg in the files folder, and thus this image tag should now read <img src="files/greece_foo.jpg"> -- so if you later wonder what are all those images belong to, you have an easier guess on which ones you may remove.


So far, this is a general explanation. If you have complex descriptions in the KML file, you may need to reformat them as well. This won't be necessary for plain flowing text, but probably will be the case for multi-column tables. Those are fine with a large monitor, but will cause a lot of scrolling on a phone display...
  •  

berkley

#1
nice manual! thanks!
Search before posting!!!
XDA Orbit, HTC Touch HD, SGS1, SGS2, Nexus S, S4 Active, OnePlus One, Innos D6000
OnePlus X
  •  

Ferretty

#2
Glad you like it! What I forgot to mention explicitely: This way one can manipulate POIs collected with Locus which where exported as KML, add images and descriptions, and make them available for others. Like the ones I posted in the "Tools & Share" area. So if there is interest, I could extend above "howto" with things like how to add descriptions and images if there are none in the KML (like those exported by Locus will probably have no images, I guess -- didn't try that yet).
  •  

Menion

Also one suggestion from me. I don't know if files directory is only valid or not, anyway locus do not support only files/... structure, so you can name your directory as you want. And I also suggest to name it in different way, to prevent overwriting and also allow to simply delete not needed images just in one directory (for one POI category)
- Official help (ideas, questions, problems): help.locusmap.eu
- Advanced topics, sharing of knowledges: you're here!
- LM 4 Beta download, LM 4 Release download
  •  

Ferretty

Yupp, OK. I will check that with the Google Specs. I took the name "files/" from what Google Earth uses; but probably the name is not important.

But yes: The KML reference simply says "An HTTP address or a local file specification used to load an icon. " And a bit later, to the <href> in a different context: "Relative URLs can be used in this tag and are evaluated relative to the enclosing KML file." The Tutorial on KMZ files also uses the example "files/" -- but from the description there I take it "an example", and not "the only valid name". In the latter case, it would explicitly state "you have to name it 'files'", which it clearly does not. More directly: "Do not use the .kmz extension for any of the subfolders within a KMZ file." clearly states what I conclude with:

In short: Name it anything you like  :mrgreen:

Edit: I added a remark to my mini-tutorial to point this out.
  •  

Szczepanik

Quote from: "Ferretty"Of course you can use any KML/KMZ offline. But if it links some images (icons and pictures), those won't be available offline if they haven't been cached before -- i.e. if you watched them all before. With version 1.9.4.2 of Locus, menion features to import KMZ files including images -- and those KMZ files I am refering to here. With a few steps, you can include the images with the KMZ, and import that file into Locus
Ferrety - thank you very much for this guide :D.  Following it carefully, I have imported Speed Camera Data Base KMZ files including images into Locus 8-). We have 5,449  (Five thousand four hundred and forty nine) speed cameras in Great Britain! :(. Now I know where the fixed ones are!
Cheers
Tom
  •  

Ferretty

Glad to read my mini-tutorial was helpful! As you converted such helpful material, did you consider to share it, attaching it to your post in the share forum? Guess there are some more British people around here who could profit from it  :P
  •  

Szczepanik

Quote from: "Ferretty"Glad to read my mini-tutorial was helpful! As you converted such helpful material, did you consider to share it, attaching it to your post in the share forum? Guess there are some more British people around here who could profit from it  :P
See
viewtopic.php?f=15&t=1095&p=6684#p6684
Now I need to work out if Locus can make a sound as I approach the POI
Cheers
Tom
  •  

Ferretty

AFAIR there was something like a POI alert in the PRO version only. And thanks for sharing!
  •  

hossini

Hi,
i tried to do exactly the same (may be i did something wrong i dont know).

- i downloaded a speedcam *.kml file with linked <href> icons from the internet.
- the file shows well in google-earth
- importing in locus works, but just the same "bump" icon shown for every poi

- i did the changings ( files/ directory, icon download into files/, changing <href> to local, zipping, renaming kmz)
- the file shows well in google-earth
- importing in locus works, but just the same "bump" icon shown for every poi

makes me crazy, is there perhaps any icon-format not supportet (they are *.gif 22x22) ?

Thanky for your help.

Locus is a great Tool :)

Greetings Hossini

PS: i can send kmz if someone wanna see
  •  

Ferretty

Hossini, to verify this you could convert the gif to png and use the png instead. Though gif is quite a standard format and should be supported, for png I'm quite sure it actually is.
  •  

hossini

Hi,

thank you for your answer.

i looked at the *.gif files, and found that they were *.png files with *.gif extention.
i renamed them and also changed the <href> path again. zipped to *.kmz.
Checked the *.kmz with google earth, everthing works there.

But in Locus there is the same "bump" icon.

next thing is that i trie to reinstall locus. may be there is something with directory rights or something in my system ???
  •  

Ferretty

Maybe you try a cleanup first: Remove the old import (POIs as well as their data on the SD card), and then try a fresh import. If that does not help, you still can uninstall/reinstall.
  •  

hossini

hi,

did cleanup,
then reinstall ... didnt work ...

may be i still do something wrong.
  •  

Ferretty

Did you try the file in Google Maps? Google Earth sometimes behaves a bit different. I noticed that with the exports made from Trip Journal: All showed fine in GE, but not in GM. If it does not show fine in GM, it usually does not show fine in Locus either.
  •